Class to handle individual model particles.
A IMP::Particle is a mapping between keys and values.
Four possible types of values:
To use an attribute you first create a key
f= IMP.FloatKey("MyAttribute")
Creating a key is expensive and should not be done often.
Then use it to manipulate the attribute.
p.add_attribute(f, initial_value, whether_attribute_is_optimized) p.set_attribute(f, new_value) p.remove_attribute(f)
This class contains particle methods and indexes to particle attributes. To prevent a particle from being moved by the optimizer during optimization, mark all of its attributes as being non-optimizable (set_is_optimized method). Note that this only affects the optimizer, ScoreStates may still change the particle attributes.
A particle may only belong to one model.
Any attempt to access or change an attribute which the particle does not have results is undefined. It will throw an exception if checks are on or possibly just crash if they are not. Likewise an attempt to touch an inactive particle is also undefined (and will throw an exception if checks are enabled).
Inheritance diagram for IMP::Particle:Public Member Functions | |
| Particle (Model *m, std::string name) | |
| Construct a particle and add it to the Model. | |
| Particle (Model *m) | |
| Construct a particle and add it to the Model. | |
| ParticleIndex | get_index () const |
| bool | get_is_active () const |
| Get whether the particle is active. | |
Static Public Member Functions | |
| static Particle * | get_from (IMP::base::Object *o) |
Attribute manipulation | |
For each type of attribute and their corresponding key type, the Particle provides the following methods. The Type is the type of the attribute (Float, Int, Particle * etc.) and KeyType is the type of the key (FloatKey, IntKey, ParticleKey etc.). | |
| void | add_attribute (KeyType name, Type initial_value) |
| void | remove_attribute (KeyType name) |
| bool | has_attribute (KeyType name) const |
| Type | get_value (KeyType name) const |
Float Attributes | |
Float attributes can be optimized, meaning the optimizer is allowed to change their value in order to improve the score. As a result, there are a number of extra methods to manipulate them. All distances are assumed to be in angstroms and derivatives in kcal/mol angstrom. This is not enforced. | |
| void | add_attribute (FloatKey name, const Float initial_value, bool optimized) |
| void | add_to_derivative (FloatKey key, Float value, const DerivativeAccumulator &da) |
| void | set_is_optimized (FloatKey k, bool tf) |
| bool | get_is_optimized (FloatKey k) const |
| Float | get_derivative (FloatKey name) const |
Particle attributes | |
| void | add_attribute (ParticleKey k, Particle *v) |
| bool | has_attribute (ParticleKey k) |
| void | set_value (ParticleKey k, Particle *v) |
| Particle * | get_value (ParticleKey k) const |
| void | remove_attribute (ParticleKey k) |
| ParticleKeys | get_particle_keys () const |
| IMP::Particle::Particle | ( | Model * | m, |
| std::string | name | ||
| ) |
Construct a particle and add it to the Model.
| bool IMP::Particle::get_is_active | ( | ) | const |
Get whether the particle is active.
Restraints referencing the particle are only evaluated for 'active' particles.