IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
Fragment.h
Go to the documentation of this file.
1/**
2 * \file IMP/atom/Fragment.h
3 * \brief A decorator for associating a Hierarchy piece
4 *
5 * Copyright 2007-2022 IMP Inventors. All rights reserved.
6 */
7
8#ifndef IMPATOM_FRAGMENT_H
9#define IMPATOM_FRAGMENT_H
10
11#include <IMP/atom/atom_config.h>
12#include "Hierarchy.h"
13#include <IMP/Decorator.h>
14
15IMPATOM_BEGIN_NAMESPACE
16
17//! A decorator to associate a particle with a part of a protein/DNA/RNA
18/** The decorator stores an optional list of residue indexes.
19 */
20class IMPATOMEXPORT Fragment : public Hierarchy {
21 static IntsKey get_begins_key();
22 static IntsKey get_ends_key();
23 static void set_residue_indexes(Model *m, ParticleIndex pi,
24 Ints ris);
25 static void set_residue_indexes(Model *m, ParticleIndex pi,
26 const IntPairs &ris);
27 static IntKey get_marker_key();
28
29 static void do_setup_particle(Model *m, ParticleIndex pi,
30 const Ints &ris = Ints()) {
31 if (!Hierarchy::get_is_setup(m, pi)) {
33 }
34 m->add_attribute(get_marker_key(), pi, 1);
35 set_residue_indexes(m, pi, ris);
36 }
37
38 static void do_setup_particle(Model *m, ParticleIndex pi,
39 Fragment o) {
40 do_setup_particle(m, pi, o.get_residue_indexes());
41 }
42
43 IntPairs get_residue_index_ranges() const;
44
45 public:
46 static bool get_is_setup(Model *m, ParticleIndex pi) {
47 return Hierarchy::get_is_setup(m, pi) &&
48 m->get_has_attribute(get_marker_key(), pi);
49 }
50
51 //! Add the residues whose indexes are listed in the passed vector
53 set_residue_indexes(get_model(), get_particle_index(), o);
54 }
55
56 Ints get_residue_indexes() const;
57
58 //! Return true if this fragment contains a given residue
59 /** This could be made more efficient. */
60 bool get_contains_residue(int rindex) const;
61
62 //! Return true if this fragment contains any of the sorted residues
63 /** The input list of residue indexes must be sorted. */
64 bool get_contains_any_sorted_residue(const Ints &rinds) const;
65
66 IMP_DECORATOR_METHODS(Fragment, Hierarchy);
68 IMP_DECORATOR_SETUP_1(Fragment, Fragment, other);
69 /** Setup a fragment with the passed residue indexes. */
70 IMP_DECORATOR_SETUP_1(Fragment, Ints, residue_indexes);
71};
72
73IMP_DECORATORS(Fragment, Fragments, Hierarchies);
74
75IMPATOM_END_NAMESPACE
76
77#endif /* IMPATOM_FRAGMENT_H */
The base class for decorators.
Decorator for helping deal with a hierarchy of molecules.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition Decorator.h:211
Model * get_model() const
Returns the Model containing the particle.
Definition Decorator.h:214
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
A decorator to associate a particle with a part of a protein/DNA/RNA.
Definition Fragment.h:20
bool get_contains_residue(int rindex) const
Return true if this fragment contains a given residue.
bool get_contains_any_sorted_residue(const Ints &rinds) const
Return true if this fragment contains any of the sorted residues.
void set_residue_indexes(Ints o)
Add the residues whose indexes are listed in the passed vector.
Definition Fragment.h:52
static bool get_is_setup(Model *m, ParticleIndex p)
Check if the particle has the needed attributes for a cast to succeed.
static Hierarchy setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor children=ParticleIndexesAdaptor())
Create a Hierarchy of level t by adding the needed attributes.
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#define IMP_DECORATOR_SETUP_0(Name)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
#define IMP_DECORATOR_METHODS(Name, Parent)
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
IMP::Vector< IntPair > IntPairs
Definition types.h:40
IMP::Vector< Int > Ints
Standard way to pass a bunch of Int values.
Definition types.h:48
Key< 1 > IntKey
The type used to identify int attributes in the Particles.
Definition base_types.h:36
Key< 5 > IntsKey
The type used to identify int attributes in the Particles.
Definition base_types.h:56