IMP Reference Guide
develop.63b38c487d,2024/12/21
The Integrative Modeling Platform
|
Interface to specialized Particle types (e.g. atoms) More...
#include <IMP/Decorator.h>
Interface to specialized Particle types (e.g. atoms)
Representation of the structure in IMP
is via a collection of Particle objects. However, since particles are general purpose, they provide a basic set of tools for managing the data (e.g. IMP::Model::add_attribute(), IMP::Model::get_value() etc). Decorators wrap (or “decorate”) particles to provide a much richer interface. For example, most particles have Cartesian coordinates. The class IMP::core::XYZ decorates such a particle to provide functions to get and set the Cartesian coordinates as well as compute distances between particles.
get_is_setup()
and setup_particle()
functions mentioned below can take any of either an IMP::Model* and IMP::ParticleIndex pair, an IMP::Particle* or another decorator to identify the particle. We use various of those below.Dealing with decorators and particles has two main parts
To set up a particle to be used with the IMP::core::XYZ decorator we do
The method call decorates the particle and also returns the decorator which can now be used to manipulate the particle. For example we can access the coordinates (0,2,3) by doing
We now say the particle is an XYZ particle. If that particle is encountered later when we do not have the existing decorator available, we can decorate it again (since it is already set up) by doing
If you do not know if pi
has been set up for the XYZ decorator, you can ask with
More abstractly, decorators can be used to
To see a list of all available decorators and to see what functions all decorators have, look at the list of classes which inherit from IMP::Decorator, below.
See the IMP::example::ExampleDecorator example for how to implement a simple decorator.
if
statements.A decorator can be cast to a IMP::Particle* in C++. In Python Decorator objects can be used anywhere where Particle or ParticleIndex objects are expected (use the get_particle() method to get the Particle itself).
See example::ExampleDecorator to see what a minimal decorator looks like.
Definition at line 119 of file Decorator.h.
Public Member Functions | |
bool | get_is_valid () const |
Returns true if constructed with a non-default constructor. More... | |
Model * | get_model () const |
Returns the Model containing the particle. More... | |
Particle * | get_particle () const |
Returns the particle decorated by this decorator. More... | |
ParticleIndex | get_particle_index () const |
Returns the particle index decorated by this decorator. More... | |
operator Particle * () const | |
operator ParticleIndex () const | |
Particle * | operator-> () const |
Protected Member Functions | |
Decorator (Model *m, ParticleIndex pi) | |
Decorator (ParticleAdaptor p) | |
bool IMP::Decorator::get_is_valid | ( | ) | const |
Returns true if constructed with a non-default constructor.
Definition at line 223 of file Decorator.h.
Model* IMP::Decorator::get_model | ( | ) | const |
Returns the Model containing the particle.
Definition at line 214 of file Decorator.h.
Particle* IMP::Decorator::get_particle | ( | ) | const |
Returns the particle decorated by this decorator.
Definition at line 194 of file Decorator.h.
ParticleIndex IMP::Decorator::get_particle_index | ( | ) | const |
Returns the particle index decorated by this decorator.
Definition at line 211 of file Decorator.h.