IMP logo
IMP Reference Guide  2.6.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 import sys
11 
12 IMP.setup_from_argv(sys.argv, "ms connectivity restraint")
13 
14 # Setup model
15 
16 m = IMP.Model()
17 ps = [IMP.Particle(m) for x in range(6)]
18 ds = []
20  ps[0], IMP.algebra.Vector3D(0.0, 0.0, 0.0)))
22  ps[1], IMP.algebra.Vector3D(1.0, 1.0, 0.0)))
24  ps[2], IMP.algebra.Vector3D(2.0, 0.0, 0.0)))
26  ps[3], IMP.algebra.Vector3D(3.0, 0.0, 0.0)))
28  ps[4], IMP.algebra.Vector3D(4.0, -1.0, 0.0)))
30  ps[5], IMP.algebra.Vector3D(1000, 1000, 1000)))
31 
32 # Create MS connectivity restraint
33 
34 ub = IMP.core.HarmonicUpperBound(1.0, 0.1)
37 
38 # Add particle types to the restraint
39 # add_type() returns a unique type handle that can be used as an argument
40 # to add_composite() later on.
41 
42 pa = r.add_type([ds[0], ds[1]])
43 pb = r.add_type([ds[2], ds[3]])
44 pc = r.add_type([ds[4]])
45 pd = r.add_type([ds[5]])
46 
47 # Enter experimental tree data into restraint
48 # In add_composite(), the first argument is node label and the second
49 # argument is the parent.
50 
51 i1 = r.add_composite([pa, pa, pb, pb, pc])
52 i2 = r.add_composite([pa, pb, pb, pc], i1)
53 i3 = r.add_composite([pa, pa, pb, pb], i1)
54 i4 = r.add_composite([pa, pb], i1)
55 i5 = r.add_composite([pa, pb, pb], i2)
56 i6 = r.add_composite([pb, pc], i2)
57 i7 = r.add_composite([pa, pa, pb], i3)
58 i8 = r.add_composite([pa, pb], i5)
59 
60 # Evaluate the restraint score
61 r.evaluate(False)