IMP  2.2.1
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 Hierachy piece
4  *
5  * Copyright 2007-2014 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 resdiue 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(kernel::Model *m, kernel::ParticleIndex pi,
24  Ints ris);
25  static void set_residue_indexes(kernel::Model *m, kernel::ParticleIndex pi,
26  const IntPairs &ris);
27  static IntKey get_marker_key();
28 
29  static void do_setup_particle(kernel::Model *m, kernel::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(kernel::Model *m, kernel::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:
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 */
Import IMP/kernel/Decorator.h in the namespace.
ParticleIndex get_particle_index() const
A base class for Keys.
Definition: kernel/Key.h:46
A decorator to associate a particle with a part of a protein/DNA/RNA.
Definition: Fragment.h:20
#define IMP_DECORATOR_METHODS(Name, Parent)
Model * get_model() const
Returns the Model containing the particle.
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex p)
Decorator for helping deal with a hierarchy of molecules.
The standard decorator for manipulating molecular structures.
static Hierarchy setup_particle(kernel::Model *m, kernel::ParticleIndex pi, kernel::ParticleIndexesAdaptor children=kernel::ParticleIndexesAdaptor())
void set_residue_indexes(Ints o)
Add the residues whose indexes are listed in the passed vector.
Definition: Fragment.h:52
#define IMP_DECORATOR_SETUP_0(Name)
Key< 5, true > IntsKey
The type used to identify int attributes in the Particles.
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72
IMP::base::Vector< Int > Ints
Standard way to pass a bunch of Int values.
Definition: base/types.h:49