IMP  2.2.1
The Integrative Modeling Platform
core/ms_connectivity_restraint.py

This example shows how to use the MSConnectivityRestraint to ensure that all the particles that are part of complexes end up in a connected conformation following the optimization. It allows multiple copies of particles and takes an experimental tree as an input.

1 ## \example core/ms_connectivity_restraint.py
2 # This example shows how to use the MSConnectivityRestraint to ensure that all the particles that are part of complexes end up in a connected conformation following the optimization. It allows multiple copies of particles and takes an experimental tree as an input.
3 #
4 
5 # -- File: ms_connectivity_restraint.py --#
6 
7 import IMP
8 import IMP.core
9 import IMP.algebra
10 
11 # Setup model
12 
13 m = IMP.kernel.Model()
14 ps = [IMP.kernel.Particle(m) for x in xrange(6)]
15 ds = []
17  ps[0], IMP.algebra.Vector3D(0.0, 0.0, 0.0)))
19  ps[1], IMP.algebra.Vector3D(1.0, 1.0, 0.0)))
21  ps[2], IMP.algebra.Vector3D(2.0, 0.0, 0.0)))
23  ps[3], IMP.algebra.Vector3D(3.0, 0.0, 0.0)))
25  ps[4], IMP.algebra.Vector3D(4.0, -1.0, 0.0)))
27  ps[5], IMP.algebra.Vector3D(1000, 1000, 1000)))
28 
29 # Create MS connectivity restraint
30 
31 ub = IMP.core.HarmonicUpperBound(1.0, 0.1)
34 
35 # Add particle types to the restraint
36 # add_type() returns a unique type handle that can be used as an argument
37 # to add_composite() later on.
38 
39 pa = r.add_type([ds[0], ds[1]])
40 pb = r.add_type([ds[2], ds[3]])
41 pc = r.add_type([ds[4]])
42 pd = r.add_type([ds[5]])
43 
44 # Enter experimental tree data into restraint
45 # In add_composite(), the first argument is node label and the second
46 # argument is the parent.
47 
48 i1 = r.add_composite([pa, pa, pb, pb, pc])
49 i2 = r.add_composite([pa, pb, pb, pc], i1)
50 i3 = r.add_composite([pa, pa, pb, pb], i1)
51 i4 = r.add_composite([pa, pb], i1)
52 i5 = r.add_composite([pa, pb, pb], i2)
53 i6 = r.add_composite([pb, pc], i2)
54 i7 = r.add_composite([pa, pa, pb], i3)
55 i8 = r.add_composite([pa, pb], i5)
56 
57 # Add restraint to the model and evaluate the model score
58 
59 m.add_restraint(r)
60 m.evaluate(False)