IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
connectivity_restraint.py
1## \example core/connectivity_restraint.py
2# This example shows how to use the ConnectivityRestraint to ensure that
3# all the particles end up in a connected conformation following the
4# optimization. One should also check out the
5# IMP::atom::create_connectivity_restraint() helper functions.
6
7import IMP
8import IMP.core
9import IMP.container
10import IMP.algebra
11import IMP.atom
12import sys
13
14IMP.setup_from_argv(sys.argv, "Connectivity restraint")
15
16m = IMP.Model()
17
18# Put the parent particles for each molecule
19hs = []
20
21# create the molecules, with 5 particles for each of 10 molecules
22for i in range(0, 10):
23 pr = IMP.Particle(m)
24 pr.set_name("root " + str(i))
26 for j in range(0, 5):
27 p = IMP.Particle(m)
28 p.set_name("fragment " + str(i) + " " + str(j))
30 d.add_child(cd)
33 hs.append(pr)
34
35
38
39# score based on the one closest particle from each set of balls
40lrps = IMP.core.KClosePairsPairScore(ps, cps, 1)
41# connect all 10 molecules together
44
45cr.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
static Fragment setup_particle(Model *m, ParticleIndex pi)
Definition Fragment.h:67
static const IMP::core::HierarchyTraits & get_traits()
Get the molecular hierarchy HierarchyTraits.
static Hierarchy setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor children=ParticleIndexesAdaptor())
Create a Hierarchy of level t by adding the needed attributes.
Return the hierarchy children of a particle.
Ensure that a set of particles remains connected with one another.
Upper bound harmonic function (non-zero when feature > mean).
Apply a score to a fixed number of close pairs from the two sets.
A score on the distance between the surfaces of two spheres.
static XYZR setup_particle(Model *m, ParticleIndex pi)
Definition XYZR.h:48
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
Functionality for loading, creating, manipulating and scoring atomic structures.
Various classes to hold sets of particles.
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.