IMP logo
IMP Reference Guide  develop.031dafb4d2,2024/05/16
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 
6 import IMP
7 import IMP.core
8 import IMP.container
9 import sys
10 
11 IMP.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 
16 diameter = 10
17 m = IMP.Model()
19  m, IMP.core.create_xyzr_particles(m, 50, 1.0))
21 r = IMP.core.DiameterRestraint(h, lc, diameter)
23 
24 # Set up optimizer
26 o.set_scoring_function(sf)
27 
28 max = 0
29 for 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
35 print("The maximum distance is " + str(max))
36 
37 IMP.set_log_level(IMP.SILENT)
38 o.optimize(100)
39 
40 max = 0
41 for 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
47 print("Afterwards, the maximum distance is " + str(max))
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
Various classes to hold sets of particles.
Upper bound harmonic function (non-zero when feature > mean)
XYZRs create_xyzr_particles(Model *m, unsigned int num, Float radius, Float box_side=10)
Create a set of particles with random coordinates.
Simple conjugate gradients optimizer.
Create a scoring function on a list of restraints.
double get_distance(XYZR a, XYZR b)
Compute the sphere distance between a and b.
Definition: XYZR.h:89
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Store a list of ParticleIndexes.
Restrain the diameter of a set of points.
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
void set_log_level(LogLevel l)
Set the current global log level.
Basic functionality that is expected to be used by a wide variety of IMP users.