IMP logo
IMP Reference Guide  2.12.0
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-2019 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 
15 IMPATOM_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  */
20 class 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 
65  /** Setup a fragment with the passed residue indexes. */
66  IMP_DECORATOR_SETUP_1(Fragment, Ints, residue_indexes);
67 };
68 
70 
71 IMPATOM_END_NAMESPACE
72 
73 #endif /* IMPATOM_FRAGMENT_H */
The base class for decorators.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition: Decorator.h:188
A decorator to associate a particle with a part of a protein/DNA/RNA.
Definition: Fragment.h:20
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Model * get_model() const
Returns the Model containing the particle.
Definition: Decorator.h:191
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
Decorator for helping deal with a hierarchy of molecules.
static Hierarchy setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor children=ParticleIndexesAdaptor())
Create a Hierarchy of level t by adding the needed attributes.
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
add particle atribute with the specied key and initial value
The standard decorator for manipulating molecular structures.
void set_residue_indexes(Ints o)
Add the residues whose indexes are listed in the passed vector.
Definition: Fragment.h:52
A base class for Keys.
Definition: Key.h:44
#define IMP_DECORATOR_SETUP_0(Name)
static bool get_is_setup(Model *m, ParticleIndex p)
Check if the particle has the needed attributes for a cast to succeed.
#define IMP_DECORATOR_METHODS(Name, Parent)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
IMP::Vector< Int > Ints
Standard way to pass a bunch of Int values.
Definition: types.h:49
bool get_has_attribute(TypeKey attribute_key, ParticleIndex particle) const
return true if particle has attribute with the specified key