IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
restrain_diameter.py
1## \example core/restrain_diameter.py
2# An example restraining the diameter of a set of points. That is, the
3# restraint penalizes conformations where there are two points more than a
4# certain distance from one another.
5
6import IMP
7import IMP.core
8import IMP.container
9import sys
10
11IMP.setup_from_argv(sys.argv, "restrain diameter")
12
13# This example restraint the diameter of a set of particles to be smaller
14# than 10
15
16diameter = 10
17m = IMP.Model()
19 m, IMP.core.create_xyzr_particles(m, 50, 1.0))
21r = IMP.core.DiameterRestraint(h, lc, diameter)
23
24# Set up optimizer
26o.set_scoring_function(sf)
27
28max = 0
29for pi0 in lc.get_contents():
30 for pi1 in lc.get_contents():
32 IMP.core.XYZ(m, pi1))
33 if d > max:
34 max = d
35print("The maximum distance is " + str(max))
36
37IMP.set_log_level(IMP.SILENT)
38o.optimize(100)
39
40max = 0
41for pi0 in lc.get_contents():
42 for pi1 in lc.get_contents():
44 IMP.core.XYZ(m, pi1))
45 if d > max:
46 max = d
47print("Afterwards, the maximum distance is " + str(max))
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Simple conjugate gradients optimizer.
Restrain the diameter of a set of points.
Upper bound harmonic function (non-zero when feature > mean).
Create a scoring function on a list of restraints.
A decorator for a particle with x,y,z coordinates.
Definition XYZ.h:30
Various classes to hold sets of particles.
Basic functionality that is expected to be used by a wide variety of IMP users.
XYZRs create_xyzr_particles(Model *m, unsigned int num, Float radius, Float box_side=10)
Create a set of particles with random coordinates.
double get_distance(const Surface &s, const XYZR &d)
Get distance from sphere to surface.
Definition Surface.h:153
void set_log_level(LogLevel l)
Set the current global log level.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.