IMP  2.1.1
The Integrative Modeling Platform
IMP::kernel::Restraint Class Reference

A restraint is a term in an IMP ScoringFunction. More...

#include "IMP/Restraint.h"

Inherits IMP::kernel::ModelObject.

Inherited by IMP::atom::CHARMMStereochemistryRestraint, IMP::atom::EzRestraint, IMP::container::MinimumPairRestraint, IMP::container::MinimumQuadRestraint, IMP::container::MinimumSingletonRestraint, IMP::container::MinimumTripletRestraint, IMP::container::PairsRestraint, IMP::container::PredicatePairsRestraint, IMP::container::PredicateQuadsRestraint, IMP::container::PredicateSingletonsRestraint, IMP::container::PredicateTripletsRestraint, IMP::container::QuadsRestraint, IMP::container::SingletonsRestraint, IMP::container::TripletsRestraint, IMP::core::ConnectivityRestraint, IMP::core::ConstantRestraint, IMP::core::DiameterRestraint, IMP::core::DihedralRestraint, IMP::core::DistanceRestraint, IMP::core::ExcludedVolumeRestraint, IMP::core::MinimumRestraint, IMP::core::MSConnectivityRestraint, IMP::core::PairRestraint, IMP::core::QuadRestraint, IMP::core::SingletonRestraint, IMP::core::TripletRestraint, IMP::core::VolumeRestraint, IMP::em2d::DummyRestraint, IMP::em2d::Em2DRestraint, IMP::em2d::Fine2DRegistrationRestraint, IMP::em2d::ParticlesDummyRestraint, IMP::em2d::RigidBodiesImageFitRestraint, IMP::em::DensityFillingRestraint, IMP::em::EnvelopeFitRestraint, IMP::em::EnvelopePenetrationRestraint, IMP::em::FitRestraint, IMP::em::PCAFitRestraint, IMP::example::ExampleComplexRestraint, IMP::example::ExampleRestraint, IMP::isd::AmbiguousNOERestraint, IMP::isd::AmbiguousRestraint, IMP::isd::CysteineCrossLinkRestraint, IMP::isd::FretRestraint, IMP::isd::GaussianProcessInterpolationRestraint, IMP::isd::GaussianRestraint, IMP::isd::JeffreysRestraint, IMP::isd::LognormalRestraint, IMP::isd::MarginalHBondRestraint, IMP::isd::MarginalNOERestraint, IMP::isd::NOERestraint, IMP::isd::TALOSRestraint, IMP::isd::vonMisesKappaConjugateRestraint, IMP::isd::vonMisesKappaJeffreysRestraint, IMP::isd::WeightRestraint, IMP::kernel::RestraintSet, IMP.modeller.ModellerRestraints, IMP::modeller::MultipleBinormalRestraint, IMP::multifit::ComplementarityRestraint, IMP::multifit::DummyRestraint, IMP::multifit::RadiusOfGyrationRestraint, IMP::multifit::WeightedExcludedVolumeRestraint, IMP::saxs::RadiusOfGyrationRestraint, IMP::saxs::Restraint, and write_a_restraint.MyRestraint.

Public Member Functions

 Restraint (kernel::Model *m, std::string name)
 
 Restraint (std::string name="Restraint %1%")
 
void add_score_and_derivatives (ScoreAccumulator sa) const
 
Restraintcreate_current_decomposition () const
 Decompose this restraint into constituent terms for the current conf. More...
 
Restraintcreate_decomposition () const
 Decompose this restraint into constituent terms. More...
 
virtual ScoringFunctioncreate_scoring_function (double weight=1.0, double max=NO_MAX) const
 
ContainersTemp get_input_containers () const
 
ParticlesTemp get_input_particles () const
 
virtual double get_last_score () const
 
double get_score () const
 
bool get_was_good () const
 
- Public Member Functions inherited from IMP::kernel::ModelObject
 ModelObject (kernel::Model *m, std::string name)
 
 ModelObject (std::string name)
 
virtual void do_set_model (kernel::Model *)
 
bool get_has_dependencies () const
 Return whether this object has dependencies computed.
 
bool get_has_required_score_states () const
 
ModelObjectsTemp get_inputs () const
 
ModelObjectsTemps get_interactions () const
 
bool get_is_part_of_model () const
 
Modelget_model () const
 
ModelObjectsTemp get_outputs () const
 
const ScoreStatesTempget_required_score_states () const
 
void set_has_dependencies (bool tf)
 
void set_has_required_score_states (bool tf)
 
virtual void set_model (kernel::Model *m)
 
- Public Member Functions inherited from IMP::base::Object
virtual void clear_caches ()
 
virtual void do_destroy ()
 
CheckLevel get_check_level () const
 
LogLevel get_log_level () const
 
virtual VersionInfo get_version_info () const
 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. More...
 
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)
 
virtual std::string get_type_name () const
 

Protected Member Functions

virtual void do_add_score_and_derivatives (ScoreAccumulator sa) const
 
virtual Restraints do_create_current_decomposition () const
 
virtual Restraints do_create_decomposition () const
 
ModelObjectsTemp do_get_outputs () const
 
- Protected Member Functions inherited from IMP::kernel::ModelObject
virtual ModelObjectsTemp do_get_inputs () const =0
 
virtual ModelObjectsTemps do_get_interactions () const
 
virtual void handle_set_has_required_score_states (bool)
 
- Protected Member Functions inherited from IMP::base::Object
 Object (std::string name)
 Construct an object with the given name. More...
 
 Object ()
 

Weights

Each restraint's contribution to the model score is weighted. The total weight for the restraint is the some over all the paths containing it. That is, if a restraint is in a RestraintSet with weight .5 and another with weight 2, and the restaint itself has weight 3, then the total weight of the restraint is \(.5 \cdot 3 + 2 \cdot 3 = 7.5 \).

void set_weight (Float weight)
 
Float get_weight () const
 

Filtering

We are typically only interested in "good" conformations of the model. These are described by specifying maximum scores per restraint and for the whole model. Samplers, optimizers etc are free to ignore configurations they encounter which go outside these bounds.

Note
The maximum score is for the unweighted restraint. That is, the restraint evaluation is bad if the value is greater than the maximum score divided by the weight.
double get_maximum_score () const
 
void set_maximum_score (double s)
 

Detailed Description

To implement a new restraint, just implement the two methods:

Note
When logging is VERBOSE, restraints should print enough information in evaluate to reproduce the the entire flow of data in evaluate. When logging is TERSE the restraint should print out only a constant number of lines per evaluate call.
Physical restraints should use the units of kcal/mol for restraint values and kcal/mol/A for derivatives.

When implementing an expensive restraint it makes sense to support early abort of evaluation if the user is only interested in good scores or scores below a threshold. To do this, look at the fields of the ScoreAccumulator object such as

See IMP::example::ExampleRestraint for an example.

Definition at line 52 of file kernel/declare_Restraint.h.

Constructor & Destructor Documentation

IMP::kernel::Restraint::Restraint ( kernel::Model m,
std::string  name 
)

Create a restraint and register it with the model. The restraint is not added to the implicit scoring function in the Model.

IMP::kernel::Restraint::Restraint ( std::string  name = "Restraint %1%")
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. Use the constructor that takes a model instead.

Member Function Documentation

void IMP::kernel::Restraint::add_score_and_derivatives ( ScoreAccumulator  sa) const

This methid is called in order to perform the actual restraint scoring. The restraints should assume that all appropriate ScoreState objects have been updated and so that the input particles and containers are up to date. The returned score should be the unweighted score.

Restraint* IMP::kernel::Restraint::create_current_decomposition ( ) const

Return a decomposition that is value for the current conformation, but will not necessarily be valid if any of the particles are changed. This is the same as create_decomposition() for non-conditional restraints.

The restraints returned have had set_model() called and so can be evaluated.

Restraint* IMP::kernel::Restraint::create_decomposition ( ) const

Given the set of input particles, decompose the restraint into as simple parts as possible. For many restraints, the simplest part is simply the restraint itself.

If a restraint can be decomposed, it should return a RestraintSet so that the maximum score and weight can be passed properly.

The restraints returned have had set_model() called and so can be evaluated.

virtual ScoringFunction* IMP::kernel::Restraint::create_scoring_function ( double  weight = 1.0,
double  max = NO_MAX 
) const
virtual

Create a scoring function with only this restarint.

Note
This method cannot be implemented in python due to memory management issues (and the question of why you would ever want to).
virtual void IMP::kernel::Restraint::do_add_score_and_derivatives ( ScoreAccumulator  sa) const
protectedvirtual
virtual Restraints IMP::kernel::Restraint::do_create_current_decomposition ( ) const
protectedvirtual

A Restraint should override this if they want to decompose themselves for display and other purposes. The returned restraints will be made in to a RestraintSet, if needed and the weight and maximum score set for the restraint set.

The returned restraints should be only the non-zero terms and should have their last scores set appropriately;

Reimplemented in IMP::core::ExcludedVolumeRestraint, IMP::core::MSConnectivityRestraint, and IMP::core::ConnectivityRestraint.

Definition at line 226 of file kernel/declare_Restraint.h.

virtual Restraints IMP::kernel::Restraint::do_create_decomposition ( ) const
protectedvirtual

A Restraint should override this if they want to decompose themselves for domino and other purposes. The returned restraints will be made in to a RestraintSet, if needed and the weight and maximum score set for the restraint set.

Reimplemented in IMP::core::ExcludedVolumeRestraint.

Definition at line 215 of file kernel/declare_Restraint.h.

ModelObjectsTemp IMP::kernel::Restraint::do_get_outputs ( ) const
protectedvirtual

No outputs.

Implements IMP::kernel::ModelObject.

Definition at line 234 of file kernel/declare_Restraint.h.

ContainersTemp IMP::kernel::Restraint::get_input_containers ( ) const
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. use get_inputs() instead.
ParticlesTemp IMP::kernel::Restraint::get_input_particles ( ) const
Deprecated:
As of IMP release 2.1. See the IMP Deprecation Policy for more information about deprecation in IMP. use get_inputs() instead.
virtual double IMP::kernel::Restraint::get_last_score ( ) const
virtual

Return the (unweighted) score for this restraint last time it was evaluated.

Note
If some sort of special evaluation (eg Model::evaluate_if_good()) was the last call, the score, if larger than the max, is not accurate.

Reimplemented in IMP::kernel::RestraintSet.

Definition at line 194 of file kernel/declare_Restraint.h.

double IMP::kernel::Restraint::get_score ( ) const

Compute and return the current score for the restraint.

bool IMP::kernel::Restraint::get_was_good ( ) const

Return whether this restraint violated it maximum last time it was evaluated.

Definition at line 198 of file kernel/declare_Restraint.h.


The documentation for this class was generated from the following file: