IMP  2.1.0
The Integrative Modeling Platform
Domain.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/Domain.h
3  * \brief A decorator for associating an atom::Hierarchy piece with a domain
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPATOM_DOMAIN_H
9 #define IMPATOM_DOMAIN_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
18 /** The decorator stores the indexes of the first and last residues
19  in this domain.
20  */
21 class IMPATOMEXPORT Domain : public Hierarchy {
22  struct Data {
23  Data() : begin("domain_begin"), end("domain_end") {}
24  IntKey begin, end;
25  };
26  static const Data &get_data();
27  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
28  IntRange r) {
29  m->add_attribute(get_data().begin, pi, r.first);
30  m->add_attribute(get_data().end, pi, r.second);
31  if (!Hierarchy::get_is_setup(m, pi)) {
33  }
34  }
35  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
36  Int b, Int e) {
37  do_setup_particle(m, pi, IntRange(b, e));
38  }
39  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
40  Domain o) {
41  do_setup_particle(m, pi, o.get_index_range());
42  }
43 
44  public:
45 
47  return m->get_has_attribute(get_data().begin, pi) &&
48  m->get_has_attribute(get_data().end, pi) &&
50  }
51 
52  void set_index_range(IntRange ir) {
53  IMP_USAGE_CHECK(ir.first < ir.second,
54  "Bad range passed: " << ir.first << "..." << ir.second);
55  get_particle()->set_value(get_data().begin, ir.first);
56  get_particle()->set_value(get_data().end, ir.second);
57  }
58  /** Get the range of indexes in the domain `[begin...end)` */
59  IntRange get_index_range() const {
60  return IntRange(
61  get_model()->get_attribute(get_data().begin, get_particle_index()),
62  get_model()->get_attribute(get_data().end, get_particle_index()));
63  }
64 
67  IMP_DECORATOR_SETUP_1(Domain, IntRange, residues);
68 
69  /** \deprecated_at{2.1} Use get_index_range() instead.*/
70  IMPATOM_DEPRECATED_METHOD_DECL(2.1)
71  Int get_begin_index() const;
72  /** \deprecated_at{2.1} Use get_index_range() instead.*/
73  IMPATOM_DEPRECATED_METHOD_DECL(2.1)
74  Int get_end_index() const;
75  /** \deprecated_at{2.1} Use the IntRange setup_particle.*/
76  IMPATOM_DEPRECATED_METHOD_DECL(2.1)
77  static Domain setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
78  Int residues_begin, Int residues_end);
79  /** \deprecated_at{2.1} Use the IntRange setup_particle.*/
80  IMPATOM_DEPRECATED_METHOD_DECL(2.1)
81  static Domain setup_particle(IMP::kernel::ParticleAdaptor decorator,
82  Int residues_begin, Int residues_end);
83 };
84 
86 
87 IMPATOM_END_NAMESPACE
88 
89 #endif /* IMPATOM_DOMAIN_H */
Import IMP/kernel/Decorator.h in the namespace.
A decorator to associate a particle with a part of a protein.
Definition: Domain.h:21
A base class for Keys.
Definition: kernel/Key.h:46
Particle * get_particle() const
#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)
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
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())
IntRange get_index_range() const
Definition: Domain.h:59
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
int Int
Basic integer value.
Definition: base/types.h:35
#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.