IMP  2.1.1
The Integrative Modeling Platform
core/restrain_diameter.py

An example restraining the diameter of a set of points. That is, the restraint penalizes conformations where there are two point more than a certain distance from one another.

1 ## \example core/restrain_diameter.py
2 # An example restraining the diameter of a set of points. That is, the
3 # restraint penalizes conformations where there are two point more than a
4 # certain distance from one another.
5 
6 import IMP
7 import IMP.core
8 import IMP.container
9 
10 # This example restraints the diameter of a set of particles to be smaller
11 # than 10
12 
13 diameter = 10
14 m = IMP.kernel.Model()
18 r = IMP.core.DiameterRestraint(h, lc, diameter)
19 m.add_restraint(r)
20 
21 # Set up optimizer
23 o.set_model(m)
24 
25 max = 0
26 for p0 in lc.get_particles():
27  for p1 in lc.get_particles():
29  IMP.core.XYZ(p1))
30  if d > max:
31  max = d
32 print "The maximim distance is " + str(max)
33 
34 IMP.base.set_log_level(IMP.base.SILENT)
35 o.optimize(100)
36 
37 max = 0
38 for p0 in lc.get_particles():
39  for p1 in lc.get_particles():
41  IMP.core.XYZ(p1))
42  if d > max:
43  max = d
44 print "Afterwards, the maximim distance is " + str(max)