IMP  2.3.1
The Integrative Modeling Platform
core/restrain_in_sphere.py

This fragment shows how to restrain a set of points stored in a SingletonContainer in a sphere of radius 'radius' centered around 'center'.

1 ## \example core/restrain_in_sphere.py
2 # This fragment shows how to restrain a set of points stored in a
3 # SingletonContainer in a sphere of radius 'radius' centered around
4 # 'center'.
5 
6 import IMP
7 import IMP.core
8 radius = 10
9 stiffness = 2
10 center = IMP.algebra.Vector3D(1, 2, 3)
11 m = IMP.kernel.Model()
12 p = m.add_particle("particle")
14  m, p, IMP.algebra.Sphere3D(IMP.algebra.Vector3D(100, 0, 0), 1))
15 
16 ub = IMP.core.HarmonicUpperBound(radius, stiffness)
17 
18 # Restrain based on the distance to a single point (hence a ball
19 ss = IMP.core.DistanceToSingletonScore(ub, center)
20 
21 r = IMP.core.SingletonRestraint(ss, m.get_particle(p))
22 r.evaluate(False)