IMP  2.2.1
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 import IMP.atom
6 import IMP.container
7 import IMP.misc
8 import IMP.display
9 import IMP.example
10 import IMP.base
11 import sys
12 import IMP.rmf
13 #import IMP.benchmark
14 import RMF
15 import random
16 
18  sys.argv, "Use the IMP::misc::DecayPairContainerOptimizerState to gradually break the bonds in a bd simulation")
19 
20 if IMP.base.get_bool_flag("run_quick_test"):
21  np = 8
22  nb = 8
23  prob = .5
24  period = 2
25  steps = 10
26 else:
27  np = 20
28  nb = 40
29  prob = .9
30  period = 10
31  steps = 10000
32 
33 m = IMP.kernel.Model()
34 
36  IMP.algebra.Vector3D(100, 100, 100))
37 ps = []
38 for i in range(0, np):
39  p = IMP.kernel.Particle(m)
41  d.set_coordinates(IMP.algebra.Vector3D(10. * (i/10), 10. * (i%10), 10.))
42  d.set_radius(10)
43  d.set_coordinates_are_optimized(True)
47  ps.append(p)
49 
50 bds = []
51 for i in range(0, nb):
52  pp = random.sample(ps, 2)
53  if pp not in bds and [pp[1], pp[0]] not in bds:
54  bds.append(pp)
55 
57 dos = IMP.misc.DecayPairContainerOptimizerState(cf, bds, "decay")
58 dos.set_period(period)
59 dos.set_log_level(IMP.base.SILENT) # VERBOSE
60 
61 # create restraints
62 rs = []
64  IMP.core.HarmonicUpperBound(0, 10), bb)
65 rs.append(IMP.container.SingletonsRestraint(box_score, ps, "box"))
67 rs.append(IMP.container.PairsRestraint(bond_score,
68  dos.get_output_container(),
69  "bonds"))
70 ev = IMP.core.ExcludedVolumeRestraint(ps, 10, 10)
71 IMP.base.set_log_level(IMP.SILENT)
72 
73 # set up simulator
75 bd.set_maximum_time_step(1000)
76 bd.set_scoring_function(rs + [ev])
77 bd.add_optimizer_state(dos)
78 
79 # set up display
80 fn = IMP.base.create_temporary_file_name("decay", ".rmf")
81 rmf = RMF.create_rmf_file(fn)
82 print "setting up file"
84 IMP.rmf.add_restraints(rmf, rs + [ev])
86 IMP.rmf.add_geometries(rmf, [g])
87 os = IMP.rmf.SaveOptimizerState(m, rmf)
88 os.set_period(max(steps / 100, 1))
89 bd.add_optimizer_state(os)
90 
91 # actually optimize things
92 print "running"
93 bd.optimize(steps)
94 
95 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)
See IMP.container for more information.
Upper bound harmonic function (non-zero when feature > mean)
See IMP.misc for more information.
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="")
Maintain a pair container with a decaying list of pairs.
See IMP.base for more information.
Definition: base/Array.h:20
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
See IMP.example for more information.
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)
See IMP.display for more information.
Definition: ChimeraWriter.h:17
See IMP.atom for more information.
See IMP.rmf for more information.
Definition: associations.h:20
Applies a PairScore to each Pair in a list.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72