IMP logo
IMP Reference Guide  develop.63b38c487d,2024/12/22
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
3 # all the particles that are part of complexes end up in a connected
4 # conformation following the optimization. It allows multiple copies of
5 # particles and takes an experimental tree as an input.
6 #
7 
8 # -- File: ms_connectivity_restraint.py --#
9 
10 import IMP
11 import IMP.core
12 import IMP.algebra
13 import sys
14 
15 IMP.setup_from_argv(sys.argv, "ms connectivity restraint")
16 
17 # Setup model
18 
19 m = IMP.Model()
20 ps = [IMP.Particle(m) for x in range(6)]
21 ds = []
23  ps[0], IMP.algebra.Vector3D(0.0, 0.0, 0.0)))
25  ps[1], IMP.algebra.Vector3D(1.0, 1.0, 0.0)))
27  ps[2], IMP.algebra.Vector3D(2.0, 0.0, 0.0)))
29  ps[3], IMP.algebra.Vector3D(3.0, 0.0, 0.0)))
31  ps[4], IMP.algebra.Vector3D(4.0, -1.0, 0.0)))
33  ps[5], IMP.algebra.Vector3D(1000, 1000, 1000)))
34 
35 # Create MS connectivity restraint
36 
37 ub = IMP.core.HarmonicUpperBound(1.0, 0.1)
40 
41 # Add particle types to the restraint
42 # add_type() returns a unique type handle that can be used as an argument
43 # to add_composite() later on.
44 
45 pa = r.add_type([ds[0], ds[1]])
46 pb = r.add_type([ds[2], ds[3]])
47 pc = r.add_type([ds[4]])
48 pd = r.add_type([ds[5]])
49 
50 # Enter experimental tree data into restraint
51 # In add_composite(), the first argument is node label and the second
52 # argument is the parent.
53 
54 i1 = r.add_composite([pa, pa, pb, pb, pc])
55 i2 = r.add_composite([pa, pb, pb, pc], i1)
56 i3 = r.add_composite([pa, pa, pb, pb], i1)
57 i4 = r.add_composite([pa, pb], i1)
58 i5 = r.add_composite([pa, pb, pb], i2)
59 i6 = r.add_composite([pb, pc], i2)
60 i7 = r.add_composite([pa, pa, pb], i3)
61 i8 = r.add_composite([pa, pb], i5)
62 
63 # Evaluate the restraint score
64 r.evaluate(False)
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
Upper bound harmonic function (non-zero when feature > mean)
static XYZ setup_particle(Model *m, ParticleIndex pi)
Definition: XYZ.h:51
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Score a pair of particles based on the distance between their centers.
Basic functionality that is expected to be used by a wide variety of IMP users.
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
VectorD< 3 > Vector3D
Definition: VectorD.h:408
Class to handle individual particles of a Model object.
Definition: Particle.h:43
Ensure that a set of particles remains connected with one another.