IMP  2.3.0
The Integrative Modeling Platform
core/connectivity_restraint.py

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.

1 ## \example core/connectivity_restraint.py
2 # This example shows how to use the ConnectivityRestraint to ensure that
3 # all the particles end up in a connected conformation following the
4 # optimization. One should also check out the
5 # IMP::atom::create_connectivity_restraint() helper functions.
6 
7 import IMP
8 import IMP.core
9 import IMP.algebra
10 import IMP.atom
11 
12 m = IMP.kernel.Model()
13 
14 # Put the parent particles for each molecule
15 hs = []
16 
17 # create the molecules, with 5 particles for each of 10 molecules
18 for i in range(0, 10):
19  pr = IMP.kernel.Particle(m)
20  pr.set_name("root " + str(i))
22  for j in range(0, 5):
23  p = IMP.kernel.Particle(m)
24  p.set_name("fragment " + str(i) + " " + str(j))
26  d.add_child(cd)
28  p, IMP.algebra.Sphere3D(IMP.algebra.Vector3D(3 * i, j, 0), 1))
29  hs.append(pr)
30 
31 
34 
35 # score based on the one closest particle from each set of balls
36 lrps = IMP.core.KClosePairsPairScore(ps, cps, 1)
37 # connect all 10 molecules together
39 cr.set_particles(hs)
40 m.add_restraint(cr)
41 
42 m.evaluate(False)