IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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-2022 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>
19
20IMPEXAMPLE_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
66IMPEXAMPLE_END_NAMESPACE
67
68#endif /* IMPEXAMPLE_CREATING_RESTRAINTS_H */
Return all pairs from a SingletonContainer.
Return all pairs from a SingletonContainer.
Store a list of ParticleIndexes.
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.
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
A restraint is a term in an IMP ScoringFunction.
Definition Restraint.h:56
Return all close unordered pairs of particles taken from the SingletonContainer.
Score distance between two particle centers using a harmonic function.
A decorator for a particle with x,y,z coordinates and a radius.
Definition XYZR.h:27
Various important functionality for implementing decorators.
A Score on the distance between a pair of particles.
Restraint * create_restraint(Score *s, Container *c, std::string name=std::string())
Restraint * create_excluded_volume(Model *m, const ParticleIndexes &ps, double k, std::string name)
Restraint * create_chain_restraint(Model *m, const ParticleIndexes &ps, double length_factor, double k, std::string name)
Vector< ParticleIndex, std::allocator< ParticleIndex > > ParticleIndexes
A list of particles, each identified by its ParticleIndex.
Definition base_types.h:199
#define IMP_NEW(Typename, varname, args)
Declare a ref counted pointer to a new object.
A smart pointer to a reference counted object.
Definition Pointer.h:88