IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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
15IMPATOM_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 */
21class 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
61 IMP_DECORATOR_SETUP_1(Domain, Domain, other);
62 IMP_DECORATOR_SETUP_1(Domain, IntRange, residues);
63};
64
65IMP_DECORATORS(Domain, Domains, Hierarchies);
66
67IMPATOM_END_NAMESPACE
68
69#endif /* IMPATOM_DOMAIN_H */
The base class for decorators.
Decorator for helping deal with a hierarchy of molecules.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition Decorator.h:211
Model * get_model() const
Returns the Model containing the particle.
Definition Decorator.h:214
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition Decorator.h:194
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
A decorator to associate a particle with a part of a protein.
Definition Domain.h:21
IntRange get_index_range() const
Definition Domain.h:54
The standard decorator for manipulating molecular structures.
static bool get_is_setup(Model *m, ParticleIndex p)
Check if the particle has the needed attributes for a cast to succeed.
static Hierarchy setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor children=ParticleIndexesAdaptor())
Create a Hierarchy of level t by adding the needed attributes.
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
#define IMP_DECORATOR_METHODS(Name, Parent)
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
Key< 1 > IntKey
The type used to identify int attributes in the Particles.
Definition base_types.h:36