IMP logo
IMP Reference Guide  2.7.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.container
10 import IMP.algebra
11 import IMP.atom
12 import sys
13 
14 IMP.setup_from_argv(sys.argv, "Connectivity restraint")
15 
16 m = IMP.Model()
17 
18 # Put the parent particles for each molecule
19 hs = []
20 
21 # create the molecules, with 5 particles for each of 10 molecules
22 for i in range(0, 10):
23  pr = IMP.Particle(m)
24  pr.set_name("root " + str(i))
26  for j in range(0, 5):
27  p = IMP.Particle(m)
28  p.set_name("fragment " + str(i) + " " + str(j))
30  d.add_child(cd)
32  p, IMP.algebra.Sphere3D(IMP.algebra.Vector3D(3 * i, j, 0), 1))
33  hs.append(pr)
34 
35 
38 
39 # score based on the one closest particle from each set of balls
40 lrps = IMP.core.KClosePairsPairScore(ps, cps, 1)
41 # connect all 10 molecules together
43 cr = IMP.core.ConnectivityRestraint(lrps, lsc)
44 
45 cr.evaluate(False)