IMP  2.0.1
The Integrative Modeling Platform
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))
19  for j in range(0,5):
20  p=IMP.Particle(m)
21  p.set_name("fragment "+str(i) + " " + str(j))
23  d.add_child(cd)
25  hs.append(pr)
26 
27 
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
35 cr.set_particles(hs)
36 m.add_restraint(cr)
37 
38 m.evaluate(False)