IMP logo
IMP Reference Guide  2.19.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-2022 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(Model *m, 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(Model *m, ParticleIndex pi,
36  Domain o) {
37  do_setup_particle(m, pi, o.get_index_range());
38  }
39 
40  public:
41  static bool get_is_setup(Model *m, ParticleIndex pi) {
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 */
The base class for decorators.
A decorator to associate a particle with a part of a protein.
Definition: Domain.h:21
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition: Decorator.h:211
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Model * get_model() const
Returns the Model containing the particle.
Definition: Decorator.h:214
A more IMP-like version of the std::vector.
Definition: Vector.h:42
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
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.
IntRange get_index_range() const
Definition: Domain.h:54
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition: Decorator.h:194
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_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
bool get_has_attribute(TypeKey attribute_key, ParticleIndex particle) const
return true if particle has attribute with the specified key