IMP  2.4.0
The Integrative Modeling Platform
creating_restraints.h
Go to the documentation of this file.
1 /**
2  * \file IMP/example/creating_restraints.h
3  * \brief A simple unary function.
4  *
5  * Copyright 2007-2015 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPEXAMPLE_CREATING_RESTRAINTS_H
10 #define IMPEXAMPLE_CREATING_RESTRAINTS_H
11 
12 #include <IMP/example/example_config.h>
14 #include <IMP/container/generic.h>
19 
20 IMPEXAMPLE_BEGIN_NAMESPACE
21 
22 /** Restrain the passed particles to be connected in a chain. The distance
23  between consecutive particles is length_factor*the sum of the radii.
24 
25  Note, this assumes that all such chains will be disjoint and so you can
26  use the container::ExclusiveConsecutivePairFilter if you want to filter
27  out all pairs of particles connected by such chain restraints.
28 
29  The restraint is not added to the model.
30 */
32  const kernel::ParticlesTemp &ps, double length_factor, double k,
33  std::string name) {
34  IMP_USAGE_CHECK(!ps.empty(), "No kernel::Particles passed.");
35  double scale = core::XYZR(ps[0]).get_radius();
37  (length_factor * 2.0 * scale, k, "chain linker %1%"));
38  // Exclusive means that the particles will be in no other
39  // ConsecutivePairContainer
40  // this assumption accelerates certain computations
42  (ps, name + " consecutive pairs"));
44  container::create_restraint(hdps.get(), cpc.get(), "chain restraint %1%");
45  // make sure it is not freed
46  return r.release();
47 }
48 
49 /** Create an excluded-volume style ClosePairsContainer based score. */
51  const kernel::ParticlesTemp &ps, double k, std::string name) {
52  IMP_USAGE_CHECK(!ps.empty(), "No kernel::Particles passed.");
53  kernel::Model *m = ps[0]->get_model();
54  double scale = core::XYZR(ps[0]).get_radius();
56  (ps, name + " list"));
57  // Create a close pair container, with a distance bound of 0 and a slack
58  // that is proportional to the particle radius
59  IMP_NEW(container::ClosePairContainer, cpc, (cores_container, 0, scale * .3));
62  container::create_restraint(hlb.get(), cpc.get());
63  m->add_restraint(r);
64  return cpc.release();
65 }
66 
67 IMPEXAMPLE_END_NAMESPACE
68 
69 #endif /* IMPEXAMPLE_CREATING_RESTRAINTS_H */
Return all pairs from a SingletonContainer.
Various important functionality for implementing decorators.
Store a list of kernel::ParticlesTemp.
Return all pairs from a SingletonContainer.
A smart pointer to a reference counted object.
Definition: Pointer.h:87
Return all close unordered pairs of particles taken from the SingletonContainer.
O * release()
Relinquish control of the raw pointer stored in the Pointer.
kernel::Restraint * create_chain_restraint(const kernel::ParticlesTemp &ps, double length_factor, double k, std::string name)
#define IMP_NEW(Typename, varname, args)
Declare a ref counted pointer to a new object.
Definition: object_macros.h:72
Store a kernel::ParticleIndexes.
A restraint is a term in an IMP ScoringFunction.
A Score on the distance between a pair of particles.
A score on the distance between the surfaces of two spheres.
container::ClosePairContainer * create_excluded_volume(const kernel::ParticlesTemp &ps, double k, std::string name)
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:170
kernel::Restraint * create_restraint(Score *s, Container *c, std::string name=std::string())
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73
A decorator for a particle with x,y,z coordinates and a radius.
Definition: XYZR.h:27