IMP  2.0.0
The Integrative Modeling Platform
ms_connectivity_restraint.py
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.Model()
14 ps= [IMP.Particle(m) for x in xrange(6)]
15 ds= []
16 ds.append(IMP.core.XYZ.setup_particle(ps[0], IMP.algebra.Vector3D(0.0, 0.0, 0.0)))
17 ds.append(IMP.core.XYZ.setup_particle(ps[1], IMP.algebra.Vector3D(1.0, 1.0, 0.0)))
18 ds.append(IMP.core.XYZ.setup_particle(ps[2], IMP.algebra.Vector3D(2.0, 0.0, 0.0)))
19 ds.append(IMP.core.XYZ.setup_particle(ps[3], IMP.algebra.Vector3D(3.0, 0.0, 0.0)))
20 ds.append(IMP.core.XYZ.setup_particle(ps[4], IMP.algebra.Vector3D(4.0, -1.0, 0.0)))
21 ds.append(IMP.core.XYZ.setup_particle(ps[5], IMP.algebra.Vector3D(1000, 1000, 1000)))
22 
23 # Create MS connectivity restraint
24 
25 ub = IMP.core.HarmonicUpperBound(1.0, 0.1)
28 
29 # Add particle types to the restraint
30 # add_type() returns a unique type handle that can be used as an argument to add_composite() later on.
31 
32 pa = r.add_type([ds[0], ds[1]])
33 pb = r.add_type([ds[2], ds[3]])
34 pc = r.add_type([ds[4]])
35 pd = r.add_type([ds[5]])
36 
37 # Enter experimental tree data into restraint
38 # In add_composite(), the first argument is node label and the second argument is the parent.
39 
40 i1 = r.add_composite([pa, pa, pb, pb, pc])
41 i2 = r.add_composite([pa, pb, pb, pc], i1)
42 i3 = r.add_composite([pa, pa, pb, pb], i1)
43 i4 = r.add_composite([pa, pb], i1)
44 i5 = r.add_composite([pa, pb, pb], i2)
45 i6 = r.add_composite([pb, pc], i2)
46 i7 = r.add_composite([pa, pa, pb], i3)
47 i8 = r.add_composite([pa, pb], i5)
48 
49 # Add restraint to the model and evaluate the model score
50 
51 m.add_restraint(r)
52 m.evaluate(False)