IMP  2.1.0
The Integrative Modeling Platform
IMP::example Namespace Reference

See IMP.example for more information.

Classes

class  ExampleComplexRestraint
 Restrain the diameter of a set of points. More...
 
class  ExampleConstraint
 A trivial constraint that just increments a counter. More...
 
class  ExampleDecorator
 A simple decorator which adds a name to a particle. More...
 
class  ExampleObject
 An example simple object which is reference counted. More...
 
class  ExamplePairScore
 Apply a harmonic to the distance between two particles. More...
 
class  ExampleRestraint
 Restrain a particle to be in the x,y plane. More...
 
class  ExampleSingletonModifier
 An example singleton modifer. More...
 
class  ExampleSubsetFilterTable
 
class  ExampleTemplateClassD
 A line segment templated on the dimension. More...
 
class  ExampleUnaryFunction
 A simple unary function. More...
 

Typedefs

typedef IMP::base::Vector
< ExampleDecorator
ExampleDecorators
 
typedef base::Vector
< base::Pointer< ExampleObject > > 
ExampleObjects
 
typedef base::Vector
< base::WeakPointer
< ExampleObject > > 
ExampleObjectsTemp
 
typedef IMP::base::Vector
< IMP::base::Pointer
< ExamplePairScore > > 
ExamplePairScores
 
typedef IMP::base::Vector
< IMP::base::WeakPointer
< ExamplePairScore > > 
ExamplePairScoresTemp
 
typedef ExampleTemplateClassD< 3 > ExampleTemplateClass3D
 
typedef base::Vector
< ExampleTemplateClassD< 3 > > 
ExampleTemplateClass3Ds
 

Functions

kernel::Restraintcreate_chain_restraint (const kernel::ParticlesTemp &ps, double length_factor, double k, std::string name)
 
container::ClosePairContainercreate_excluded_volume (const kernel::ParticlesTemp &ps, double k, std::string name)
 
core::MonteCarloMovercreate_serial_mover (const kernel::ParticlesTemp &ps)
 
std::string get_data_path (std::string file_name)
 Return the full path to installed data. More...
 
std::string get_example_path (std::string file_name)
 Return the path to installed example data for this module. More...
 
unsigned int get_number_of_incidences (const kernel::ParticlesTemp &psa, const kernel::ParticlesTemp &psb, double point_distance)
 
void optimize_assembly (kernel::Model *m, const kernel::ParticlesTemp &components, const kernel::RestraintsTemp &interactions, const kernel::RestraintsTemp &other_restraints, const algebra::BoundingBox3D &bb, PairScore *ev, double cutoff, const PairPredicates &excluded=PairPredicates())
 
void optimize_balls (const kernel::ParticlesTemp &ps, const kernel::RestraintsTemp &rs=kernel::RestraintsTemp(), const PairPredicates &excluded=PairPredicates(), const OptimizerStates &opt_states=OptimizerStates(), base::LogLevel ll=base::DEFAULT)
 
template<class ParticlesList , class BoundingVolume >
void randomize_particles (const ParticlesList &ps, const BoundingVolume &bv)
 
template<class RigidBody , class BoundingVolume >
void randomize_rigid_body (RigidBody rbi, const BoundingVolume &bv)
 

Standard module methods

All IMP modules have a set of standard methods to help get information about the module and about files associated with the module.

std::string get_module_version ()
 
std::string get_module_name ()
 

Typedef Documentation

Store a set of objects.

Definition at line 39 of file ExamplePairScore.h.

Pass a \ set of \ objects. \ See \ ExamplePairScore

Definition at line 39 of file ExamplePairScore.h.

Function Documentation

kernel::Restraint* IMP::example::create_chain_restraint ( const kernel::ParticlesTemp &  ps,
double  length_factor,
double  k,
std::string  name 
)

Restrain the passed particles to be connected in a chain. The distance between consecutive particles is length_factor*the sum of the radii.

Note, this assumes that all such chains will be disjoint and so you can use the container::ExclusiveConsecutivePairFilter if you want to filter out all pairs of particles connected by such chain restraints.

The restraint is not added to the model.

Definition at line 31 of file creating_restraints.h.

+ Here is the call graph for this function:

container::ClosePairContainer* IMP::example::create_excluded_volume ( const kernel::ParticlesTemp &  ps,
double  k,
std::string  name 
)

Create an excluded-volume style ClosePairsContainer based score.

Definition at line 50 of file creating_restraints.h.

+ Here is the call graph for this function:

core::MonteCarloMover* IMP::example::create_serial_mover ( const kernel::ParticlesTemp &  ps)

Create a serial mover from a list of core::XYZR particles.

std::string IMP::example::get_data_path ( std::string  file_name)

Each module has its own data directory, so be sure to use the version of this function in the correct module. To read the data file "data_library" that was placed in the data directory of module "mymodule", do something like

std::ifstream in(IMP::mymodule::get_data_path("data_library"));

This will ensure that the code works when IMP is installed or used via the setup_environment.sh script.

std::string IMP::example::get_example_path ( std::string  file_name)

Each module has its own example directory, so be sure to use the version of this function in the correct module. For example to read the file example_protein.pdb located in the examples directory of the IMP::atom module, do

model));

This will ensure that the code works when IMP is installed or used via the setup_environment.sh script.

unsigned int IMP::example::get_number_of_incidences ( const kernel::ParticlesTemp &  psa,
const kernel::ParticlesTemp &  psb,
double  point_distance 
)

Return the number of times particles from one set are close to those from another set.

Note
This method uses the distance between the centers of the particles and does not use their radii.

Definition at line 23 of file counting.h.

+ Here is the call graph for this function:

void IMP::example::optimize_assembly ( kernel::Model *  m,
const kernel::ParticlesTemp &  components,
const kernel::RestraintsTemp &  interactions,
const kernel::RestraintsTemp &  other_restraints,
const algebra::BoundingBox3D &  bb,
PairScore *  ev,
double  cutoff,
const PairPredicates &  excluded = PairPredicates() 
)

Provide an example of a more involved protocol for assembly a complex. The protocol adds the particles one at a time based on how well connected they are to the already added particles (in the interaction graph). After each addition, the assembly is optimized. The protocol seems to work at assembling the residues of a protein from a truncated distance matrix.

void IMP::example::optimize_balls ( const kernel::ParticlesTemp &  ps,
const kernel::RestraintsTemp &  rs = kernel::RestraintsTemp(),
const PairPredicates &  excluded = PairPredicates(),
const OptimizerStates &  opt_states = OptimizerStates(),
base::LogLevel  ll = base::DEFAULT 
)

Take a set of core::XYZR particles and relax them relative to a set of restraints. Excluded volume is handle separately, so don't include it in the passed list of restraints.

/**
* \file optimize_balls.cpp
* \brief A Score on the distance between a pair of particles.
*
* Copyright 2007-2013 IMP Inventors. All rights reserved.
*/
#include <boost/ptr_container/ptr_vector.hpp>
#include <IMP/scoped.h>
/*
\example optimize_balls.cpp
This is a C++ equivalent to the optimize_balls.py python example.
*/
IMPEXAMPLE_BEGIN_NAMESPACE
core::MonteCarloMover *create_serial_mover(const kernel::ParticlesTemp &ps) {
for (unsigned int i = 0; i < ps.size(); ++i) {
double scale = core::XYZR(ps[i]).get_radius();
movers.push_back(new core::BallMover(ps[i]->get_model(),
ps[i]->get_index(), scale * 2));
}
IMP_NEW(core::SerialMover, sm, (get_as<core::MonteCarloMoversTemp>(movers)));
return sm.release();
}
/** Take a set of core::XYZR particles and relax them relative to a set of
restraints. Excluded volume is handle separately, so don't include it
in the passed list of restraints. */
void optimize_balls(const kernel::ParticlesTemp &ps, const kernel::RestraintsTemp &rs,
const PairPredicates &excluded,
const OptimizerStates &opt_states, base::LogLevel ll) {
// make sure that errors and log messages are marked as coming from this
// function
base::SetLogState sls(ll);
IMP_ALWAYS_CHECK(!ps.empty(), "No kernel::Particles passed.", ValueException);
kernel::Model *m = ps[0]->get_model();
//double scale = core::XYZR(ps[0]).get_radius();
IMP_NEW(core::SoftSpherePairScore, ssps, (10));
IMP_NEW(core::ConjugateGradients, cg, (m));
cg->set_optimizer_states(opt_states);
{
// set up restraints for cg
IMP_NEW(container::ListSingletonContainer, lsc, (ps));
IMP_NEW(container::ClosePairContainer, cpc,
(lsc, 0, core::XYZR(ps[0]).get_radius()));
cpc->add_pair_filters(excluded);
base::Pointer<kernel::Restraint> r
= container::create_restraint(ssps.get(), cpc.get());
cg->set_scoring_function(rs + kernel::RestraintsTemp(1, r.get()));
cg->set_optimizer_states(opt_states);
}
IMP_NEW(core::MonteCarlo, mc, (m));
mc->set_optimizer_states(opt_states);
IMP_NEW(core::IncrementalScoringFunction, isf, (ps, rs));
{
// set up MC
mc->add_mover(create_serial_mover(ps));
// we are special casing the nbl term for montecarlo, but using all for CG
mc->set_incremental_scoring_function(isf);
// use special incremental support for the non-bonded part
isf->add_close_pair_score(ssps, 0, ps, excluded);
// make pointer vector
}
IMP_LOG_PROGRESS("Performing initial optimization" << std::endl);
{
boost::ptr_vector<ScopedSetFloatAttribute> attrs;
for (unsigned int j = 0; j < attrs.size(); ++j) {
attrs.push_back(
}
cg->optimize(1000);
}
// shrink each of the particles, relax the configuration, repeat
for (int i = 0; i < 11; ++i) {
boost::ptr_vector<ScopedSetFloatAttribute> attrs;
double factor = .1 * i;
IMP_LOG_PROGRESS("Optimizing with radii at " << factor << " of full"
<< std::endl);
for (unsigned int j = 0; j < ps.size(); ++j) {
attrs.push_back(
core::XYZR(ps[j]).get_radius() * factor));
}
// changed all radii
isf->set_moved_particles(isf->get_movable_indexes());
for (int j = 0; j < 5; ++j) {
mc->set_kt(100.0 / (3 * j + 1));
mc->optimize(ps.size() * (j + 1) * 100);
double e = cg->optimize(10);
IMP_LOG_PROGRESS("Energy is " << e << std::endl);
if (e < .000001) break;
}
}
}
IMPEXAMPLE_END_NAMESPACE
template<class ParticlesList , class BoundingVolume >
void IMP::example::randomize_particles ( const ParticlesList &  ps,
const BoundingVolume &  bv 
)

Randomize the positions of a set of particles within a bounding volume. Rigid bodies have their orientation randomized too.

Definition at line 32 of file randomizing.h.

+ Here is the call graph for this function: