IMP
2.0.1
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
connectivity_restraint.py
1
## \example core/connectivity_restraint.py
2
## This example shows how to use the ConnectivityRestraint to ensure that all the particles end up in a connected conformation following the optimization. One should also check out the IMP::atom::create_connectivity_restraint() helper functions.
3
4
import
IMP
5
import
IMP.core
6
import
IMP.algebra
7
import
IMP.atom
8
9
m=
IMP.Model
()
10
11
# Put the parent particles for each molecule
12
hs=[]
13
14
# create the molecules, with 5 particles for each of 10 molecules
15
for
i
in
range(0,10):
16
pr=
IMP.Particle
(m)
17
pr.set_name(
"root "
+str(i))
18
d=
IMP.atom.Hierarchy.setup_particle
(pr)
19
for
j
in
range(0,5):
20
p=
IMP.Particle
(m)
21
p.set_name(
"fragment "
+str(i) +
" "
+ str(j))
22
cd=
IMP.atom.Fragment.setup_particle
(p)
23
d.add_child(cd)
24
xd=
IMP.core.XYZR.setup_particle
(p,
IMP.algebra.Sphere3D
(
IMP.algebra.Vector3D
(3*i,j,0), 1))
25
hs.append(pr)
26
27
28
ps=
IMP.core.SphereDistancePairScore
(
IMP.core.HarmonicUpperBound
(0,1))
29
cps=
IMP.core.ChildrenRefiner
(
IMP.atom.Hierarchy.get_traits
())
30
31
# score based on the one closest particle from each set of balls
32
lrps =
IMP.core.KClosePairsPairScore
(ps, cps, 1)
33
# connect all 10 molecules together
34
cr =
IMP.core.ConnectivityRestraint
(lrps)
35
cr.set_particles(hs)
36
m.add_restraint(cr)
37
38
m.evaluate(
False
)