IMP
2.0.0
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
restrain_diameter.py
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
()
12
lc=
IMP.container.ListSingletonContainer
(
IMP.core.create_xyzr_particles
(m, 50, 1.0))
13
h=
IMP.core.HarmonicUpperBound
(0,1)
14
r=
IMP.core.DiameterRestraint
(h, lc, diameter)
15
m.add_restraint(r)
16
17
# Set up optimizer
18
o=
IMP.core.ConjugateGradients
()
19
o.set_model(m)
20
21
max=0
22
for
p0
in
lc.get_particles():
23
for
p1
in
lc.get_particles():
24
d=
IMP.core.get_distance
(
IMP.core.XYZ
(p0),
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():
35
d=
IMP.core.get_distance
(
IMP.core.XYZ
(p0),
36
IMP.core.XYZ
(p1))
37
if
d > max: max=d
38
print
"Afterwards, the maximim distance is "
+str(max)