IMP logo
IMP Reference Guide  2.15.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-2021 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 ParticleIndexes &ps, double length_factor, double k,
33  std::string name) {
34  IMP_USAGE_CHECK(!ps.empty(), "No ParticleIndexes passed.");
35  double scale = core::XYZR(m, 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  (m, 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 ClosePairContainer based score. */
51  Model *m, const ParticleIndexes &ps, double k, std::string name) {
52  IMP_USAGE_CHECK(!ps.empty(), "No ParticleIndexes passed.");
53  //Model *m = ps[0]->get_model();
54  double scale = core::XYZR(m, ps[0]).get_radius();
56  (m, 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  return r.release();
64 }
65 
66 IMPEXAMPLE_END_NAMESPACE
67 
68 #endif /* IMPEXAMPLE_CREATING_RESTRAINTS_H */
O * release()
Relinquish control of the raw pointer stored in the Pointer.
Return all pairs from a SingletonContainer.
Various important functionality for implementing decorators.
Store a list of ParticleIndexes.
Restraint * create_restraint(Score *s, Container *c, std::string name=std::string())
Return all pairs from a SingletonContainer.
Return all close unordered pairs of particles taken from the SingletonContainer.
Restraint * create_excluded_volume(Model *m, const ParticleIndexes &ps, double k, std::string name)
A smart pointer to a reference counted object.
Definition: Pointer.h:87
#define IMP_NEW(Typename, varname, args)
Declare a ref counted pointer to a new object.
Definition: object_macros.h:64
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
Store a list of ParticleIndexes.
A Score on the distance between a pair of particles.
A score on the distance between the surfaces of two spheres.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
Restraint * create_chain_restraint(Model *m, const ParticleIndexes &ps, double length_factor, double k, std::string name)
A restraint is a term in an IMP ScoringFunction.
Definition: Restraint.h:54
A decorator for a particle with x,y,z coordinates and a radius.
Definition: XYZR.h:27