IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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
10import IMP
11import IMP.core
12import IMP.algebra
13import sys
14
15IMP.setup_from_argv(sys.argv, "ms connectivity restraint")
16
17# Setup model
18
19m = IMP.Model()
20ps = [IMP.Particle(m) for x in range(6)]
21ds = []
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
37ub = 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
45pa = r.add_type([ds[0], ds[1]])
46pb = r.add_type([ds[2], ds[3]])
47pc = r.add_type([ds[4]])
48pd = 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
54i1 = r.add_composite([pa, pa, pb, pb, pc])
55i2 = r.add_composite([pa, pb, pb, pc], i1)
56i3 = r.add_composite([pa, pa, pb, pb], i1)
57i4 = r.add_composite([pa, pb], i1)
58i5 = r.add_composite([pa, pb, pb], i2)
59i6 = r.add_composite([pb, pc], i2)
60i7 = r.add_composite([pa, pa, pb], i3)
61i8 = r.add_composite([pa, pb], i5)
62
63# Evaluate the restraint score
64r.evaluate(False)
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Class to handle individual particles of a Model object.
Definition Particle.h:45
Score a pair of particles based on the distance between their centers.
Upper bound harmonic function (non-zero when feature > mean).
Ensure that a set of particles remains connected with one another.
static XYZ setup_particle(Model *m, ParticleIndex pi)
Definition XYZ.h:51
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
VectorD< 3 > Vector3D
Definition VectorD.h:407
Basic functionality that is expected to be used by a wide variety of IMP users.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.