IMP  2.4.0
The Integrative Modeling Platform
decay.py
1 ## \example misc/decay.py
2 # Use the IMP::misc::DecayPairContainerOptimizerState to gradually break
3 # the bonds in a bd simulation.
4 
5 from __future__ import print_function
6 import IMP.atom
7 import IMP.container
8 import IMP.misc
9 import IMP.display
10 import IMP.example
11 import IMP.base
12 import sys
13 import IMP.rmf
14 #import IMP.benchmark
15 import RMF
16 import random
17 
19  sys.argv, "Use the IMP::misc::DecayPairContainerOptimizerState to gradually break the bonds in a bd simulation")
20 
21 if IMP.base.get_bool_flag("run_quick_test"):
22  np = 8
23  nb = 8
24  prob = .5
25  period = 2
26  steps = 10
27 else:
28  np = 20
29  nb = 40
30  prob = .9
31  period = 10
32  steps = 10000
33 
34 m = IMP.kernel.Model()
35 
37  IMP.algebra.Vector3D(100, 100, 100))
38 ps = []
39 for i in range(0, np):
40  p = IMP.kernel.Particle(m)
42  d.set_coordinates(IMP.algebra.Vector3D(10. * (i/10), 10. * (i%10), 10.))
43  d.set_radius(10)
44  d.set_coordinates_are_optimized(True)
48  ps.append(p)
50 
51 bds = []
52 for i in range(0, nb):
53  pp = random.sample(ps, 2)
54  if pp not in bds and [pp[1], pp[0]] not in bds:
55  bds.append(pp)
56 
58 dos = IMP.misc.DecayPairContainerOptimizerState(cf, bds, "decay")
59 dos.set_period(period)
60 dos.set_log_level(IMP.base.SILENT) # VERBOSE
61 
62 # create restraints
63 rs = []
65  IMP.core.HarmonicUpperBound(0, 10), bb)
66 rs.append(IMP.container.SingletonsRestraint(box_score, ps, "box"))
68 rs.append(IMP.container.PairsRestraint(bond_score,
69  dos.get_output_container(),
70  "bonds"))
71 ev = IMP.core.ExcludedVolumeRestraint(ps, 10, 10)
72 IMP.base.set_log_level(IMP.SILENT)
73 
74 # set up simulator
76 bd.set_maximum_time_step(1000)
77 bd.set_scoring_function(rs + [ev])
78 bd.add_optimizer_state(dos)
79 
80 # set up display
81 fn = IMP.base.create_temporary_file_name("decay", ".rmf")
82 rmf = RMF.create_rmf_file(fn)
83 print("setting up file")
85 IMP.rmf.add_restraints(rmf, rs + [ev])
87 IMP.rmf.add_geometries(rmf, [g])
88 os = IMP.rmf.SaveOptimizerState(m, rmf)
89 os.set_period(max(steps / 100, 1))
90 bd.add_optimizer_state(os)
91 
92 # actually optimize things
93 print("running")
94 bd.optimize(steps)
95 
96 print("see", fn)
Applies a SingletonScore to each Singleton in a list.
A harmonic upper bound on the distance between two spheres.
void add_restraints(RMF::NodeHandle fh, const kernel::Restraints &hs)
Various classes to hold sets of particles.
Upper bound harmonic function (non-zero when feature > mean)
Miscellaneous functionality that is not expected to be used by many IMP users.
void set_log_level(LogLevel l)
Set the current global log level.
bool get_bool_flag(std::string name)
std::string create_temporary_file_name(std::string prefix="imp_temp", std::string suffix="")
Create a temporary file.
Maintain a pair container with a decaying list of pairs.
Low level functionality (logging, error handling, profiling, command line flags etc) that is used by ...
Score particles based on how far outside a box they are.
static XYZR setup_particle(kernel::Model *m, ParticleIndex pi)
Definition: XYZR.h:48
Simple Brownian dynamics simulator.
static Hierarchy setup_particle(kernel::Model *m, kernel::ParticleIndex pi, kernel::ParticleIndexesAdaptor children=kernel::ParticleIndexesAdaptor())
static Colored setup_particle(kernel::Model *m, ParticleIndex pi, Color color)
Definition: Colored.h:62
Color get_display_color(unsigned int i)
void add_hierarchies(RMF::NodeHandle fh, const atom::Hierarchies &hs)
Class to handle individual model particles.
void add_geometries(RMF::NodeHandle parent, const display::GeometriesTemp &r)
static Mass setup_particle(kernel::Model *m, ParticleIndex pi, Float mass)
Definition: Mass.h:44
Example module.
VectorD< 3 > Vector3D
Definition: VectorD.h:395
Prevent a set of particles and rigid bodies from inter-penetrating.
static Diffusion setup_particle(kernel::Model *m, ParticleIndex pi, Float D)
Definition: Diffusion.h:50
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
Output IMP model data in various file formats.
Functionality for loading, creating, manipulating and scoring atomic structures.
Support for the RMF file format for storing hierarchical molecular data and markup.
Applies a PairScore to each Pair in a list.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73