IMP logo
IMP Reference Guide  2.21.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 points 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 points more than a
4 # certain distance from one another.
5 
6 import IMP
7 import IMP.core
8 import IMP.container
9 import sys
10 
11 IMP.setup_from_argv(sys.argv, "restrain diameter")
12 
13 # This example restraint the diameter of a set of particles to be smaller
14 # than 10
15 
16 diameter = 10
17 m = IMP.Model()
19  m, IMP.core.create_xyzr_particles(m, 50, 1.0))
21 r = IMP.core.DiameterRestraint(h, lc, diameter)
23 
24 # Set up optimizer
26 o.set_scoring_function(sf)
27 
28 max = 0
29 for pi0 in lc.get_contents():
30  for pi1 in lc.get_contents():
32  IMP.core.XYZ(m, pi1))
33  if d > max:
34  max = d
35 print("The maximum distance is " + str(max))
36 
37 IMP.set_log_level(IMP.SILENT)
38 o.optimize(100)
39 
40 max = 0
41 for pi0 in lc.get_contents():
42  for pi1 in lc.get_contents():
44  IMP.core.XYZ(m, pi1))
45  if d > max:
46  max = d
47 print("Afterwards, the maximum distance is " + str(max))