IMP  2.0.0
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 restraint penalizes conformations where there are two point more than a certain distance from one another.
3 
4 import IMP
5 import IMP.core
6 import IMP.container
7 
8 # This example restraints the diameter of a set of particles to be smaller than 10
9 
10 diameter=10
11 m= IMP.Model()
14 r=IMP.core.DiameterRestraint(h, lc, diameter)
15 m.add_restraint(r)
16 
17 # Set up optimizer
19 o.set_model(m)
20 
21 max=0
22 for p0 in lc.get_particles():
23  for p1 in lc.get_particles():
25  IMP.core.XYZ(p1))
26  if d > max: max=d
27 print "The maximim distance is "+str(max)
28 
29 IMP.base.set_log_level(IMP.base.SILENT)
30 o.optimize(100)
31 
32 max=0
33 for p0 in lc.get_particles():
34  for p1 in lc.get_particles():
36  IMP.core.XYZ(p1))
37  if d > max: max=d
38 print "Afterwards, the maximim distance is "+str(max)