Apply a PairFunction to a PairContainer to maintain an invariant.
The score state is passed up to two PairModifiers, one to apply before evaluation and the other after. The one after should take a DerivativeAccumulator as its last argument for PairModifier::apply() and will only be called if the score was computed with derivatives.
An example showing a how to use such a score state to maintain a cover of the atoms of a protein by a sphere per residue.
import IMP
import IMP.core
import IMP.atom
import IMP.atom
m= IMP.Model()
prot= IMP.atom.read_pdb(IMP.core.get_example_path('example_protein.pdb'), m)
res= IMP.atom.get_by_type(prot, IMP.atom.RESIDUE_TYPE)
pr= IMP.core.ChildrenRefiner(IMP.atom.Hierarchy.get_traits())
for r in res:
# add coordinates and a radius to the residue particle
IMP.core.XYZR.setup_particle(r)
# make sure that the coordinates and the radius define a sphere
# which contains all of the leaves (atoms) of the residue
IMP.core.Cover.setup_particle(r.get_particle(), pr)
# update the coordinates of the residue particles so that they cover the atoms
m.update()
Inheritance diagram for IMP::container::PairsConstraint:Public Member Functions | |
| PairsConstraint (PairModifier *before, PairDerivativeModifier *after, PairContainerInput c, std::string name="PairConstraint %1%") | |
| ScoreStates | create_decomposition () const |
| void | set_after_evaluate_modifier (PairDerivativeModifier *f) |
| Apply this modifier to all the elements after an evaluate. | |
| void | set_before_evaluate_modifier (PairModifier *f) |
| Apply this modifier to all the elements before an evaluate. | |
Public Member Functions inherited from IMP::Constraint | |
| Constraint (Model *m, std::string name="Constraint %1%") | |
Public Member Functions inherited from IMP::ScoreState | |
| ScoreState (Model *m, std::string name="ScoreState %1%") | |
| void | after_evaluate (DerivativeAccumulator *accpt) |
| void | before_evaluate () |
Public Member Functions inherited from IMP::ModelObject | |
| ModelObject (Model *m, std::string name) | |
| ModelObjectsTemp | get_inputs () const |
| Model * | get_model () const |
| ModelObjectsTemp | get_outputs () const |
Public Member Functions inherited from IMP::base::Object | |
| std::size_t | __hash__ () const |
| virtual std::string | get_type_name () const =0 |
| Return a string identifying the type of the object. | |
| virtual IMP::base::VersionInfo | get_version_info () const =0 |
| Get information about the module and version of the object. | |
| void | set_check_level (CheckLevel l) |
| void | set_log_level (LogLevel l) |
| Set the logging level used in this object. | |
| void | set_was_used (bool tf) const |
| void | show (std::ostream &out=std::cout) const |
| const std::string & | get_name () const |
| void | set_name (std::string name) |
Static Public Member Functions | |
| static PairsConstraint * | get_from (IMP::base::Object *o) |
Protected Member Functions | |
| void | do_update_attributes () |
| void | do_update_derivatives (DerivativeAccumulator *da) |
| virtual ContainersTemp | get_input_containers () const |
| virtual ParticlesTemp | get_input_particles () const |
| virtual ContainersTemp | get_output_containers () const |
| virtual ParticlesTemp | get_output_particles () const |
| IMP::container::PairsConstraint::PairsConstraint | ( | PairModifier * | before, |
| PairDerivativeModifier * | after, | ||
| PairContainerInput | c, | ||
| std::string | name = "PairConstraint %1%" |
||
| ) |
| [in] | c | The Container to hold the elements to process |
| [in] | before | The PairModifier to apply to all elements before evaluate. |
| [in] | after | The PairModifier to apply to all elements after evaluate. |
| [in] | name | The object name |
| void IMP::container::PairsConstraint::set_after_evaluate_modifier | ( | PairDerivativeModifier * | f | ) |
Apply this modifier to all the elements after an evaluate.
| void IMP::container::PairsConstraint::set_before_evaluate_modifier | ( | PairModifier * | f | ) |
Apply this modifier to all the elements before an evaluate.