IMP  2.2.1
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-2014 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  Domain o) {
37  do_setup_particle(m, pi, o.get_index_range());
38  }
39 
40  public:
42  return m->get_has_attribute(get_data().begin, pi) &&
43  m->get_has_attribute(get_data().end, pi) &&
45  }
46 
47  void set_index_range(IntRange ir) {
48  IMP_USAGE_CHECK(ir.first < ir.second,
49  "Bad range passed: " << ir.first << "..." << ir.second);
50  get_particle()->set_value(get_data().begin, ir.first);
51  get_particle()->set_value(get_data().end, ir.second);
52  }
53  /** Get the range of indexes in the domain `[begin...end)` */
54  IntRange get_index_range() const {
55  return IntRange(
56  get_model()->get_attribute(get_data().begin, get_particle_index()),
57  get_model()->get_attribute(get_data().end, get_particle_index()));
58  }
59 
62  IMP_DECORATOR_SETUP_1(Domain, IntRange, residues);
63 };
64 
66 
67 IMPATOM_END_NAMESPACE
68 
69 #endif /* IMPATOM_DOMAIN_H */
Import IMP/kernel/Decorator.h in the namespace.
ParticleIndex get_particle_index() const
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:54
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