IMP logo
IMP Reference Guide  2.12.0
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 import sys
9 
10 IMP.setup_from_argv(sys.argv, "restrain in sphere")
11 
12 radius = 10
13 stiffness = 2
14 center = IMP.algebra.Vector3D(1, 2, 3)
15 m = IMP.Model()
16 p = m.add_particle("particle")
18  m, p, IMP.algebra.Sphere3D(IMP.algebra.Vector3D(100, 0, 0), 1))
19 
20 ub = IMP.core.HarmonicUpperBound(radius, stiffness)
21 
22 # Restrain based on the distance to a single point (hence a ball
23 ss = IMP.core.DistanceToSingletonScore(ub, center)
24 
25 r = IMP.core.SingletonRestraint(m, ss, p)
26 r.evaluate(False)