IMP
2.0.0
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
restrain_minimum_distance.py
1
## \example core/restrain_minimum_distance.py
2
## This example shows how to restrain based on the minimum distance between two arbitrary sets of particles. You should also see IMP::atom::create_distance_restraint() for a related helper function.
3
4
import
IMP
5
import
IMP.core
6
m=
IMP.Model
()
7
8
# stuff to create some XYZR particles
9
ds0=
IMP.core.create_xyzr_particles
(m, 10, 1, 50)
10
ds1=
IMP.core.create_xyzr_particles
(m, 10, 1, 50)
11
12
# first create a table mapping a sentinenal particle to each set
13
tref=
IMP.core.TableRefiner
()
14
tref.add_particle(ds0[0], ds0)
15
tref.add_particle(ds1[0], ds1)
16
17
# create a pair score to apply to the closest pair
18
hps=
IMP.core.HarmonicSphereDistancePairScore
(0, 1)
19
# create the pair score with this refiner telling it to use the
20
# single closest particle
21
ps=
IMP.core.KClosePairsPairScore
(hps, tref, 1)
22
23
# create a restraint by binding the pair score to the sentinal particles
24
r=
IMP.core.PairRestraint
(ps, (ds0[0], ds1[0]),
"distance"
)
25
26
mc=
IMP.core.MonteCarlo
(m)
27
bm=
IMP.core.BallMover
(ds0+ds1, 1)
28
mc.add_mover(bm)
29
mc.set_scoring_function([r])
30
mc.optimize(1000)
31
32
# find out which pair ended up close
33
for
p0
in
ds0:
34
for
p1
in
ds1:
35
if
IMP.core.get_distance
(p0, p1) <.1:
36
print
p0, p1