IMP  2.1.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 Hierachy piece
4  *
5  * Copyright 2007-2013 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  public:
44 
46  return Hierarchy::get_is_setup(m, pi) &&
47  m->get_has_attribute(get_marker_key(), pi);
48  }
49 
50  //! Add the residues whose indexes are listed in the passed vector
52  set_residue_indexes(get_model(), get_particle_index(), o);
53  }
54 
55  Ints get_residue_indexes() const;
56 
57  /** \deprecated_at{2.1} Use the get_residue_indexes() method instead. */
58  IMPATOM_DEPRECATED_FUNCTION_DECL(2.1)
59  IntPairs get_residue_index_ranges() const;
60 
61  //! Return true if this fragment contains a given residue
62  /** This could be made more efficient. */
63  bool get_contains_residue(int rindex) const;
64 
67  IMP_DECORATOR_SETUP_1(Fragment, Fragment, other);
68  /** Setup a fragment with the passed residue indexes. */
69  IMP_DECORATOR_SETUP_1(Fragment, Ints, residue_indexes);
70 };
71 
73 
74 IMPATOM_END_NAMESPACE
75 
76 #endif /* IMPATOM_FRAGMENT_H */
Import IMP/kernel/Decorator.h in the namespace.
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:51
#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.
IMP::base::Vector< Int > Ints
Standard way to pass a bunch of Int values.
Definition: base/types.h:49