IMP  2.1.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 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.get_random_vector_in(bb))
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 # equilibrate
72 print "equilibrating"
73 IMP.base.set_log_level(IMP.PROGRESS)
74 # IMP.benchmark.set_is_profiling(True)
76 IMP.base.set_log_level(IMP.SILENT)
77 
78 # set up simulator
80 bd.set_maximum_time_step(1000)
81 bd.set_scoring_function(rs + [ev])
82 bd.add_optimizer_state(dos)
83 
84 # set up display
85 fn = IMP.base.create_temporary_file_name("decay", ".rmf")
86 rmf = RMF.create_rmf_file(fn)
87 print "setting up file"
89 IMP.rmf.add_restraints(rmf, rs + [ev])
91 IMP.rmf.add_geometries(rmf, [g])
92 os = IMP.rmf.SaveOptimizerState(m, rmf)
93 os.set_period(max(steps / 100, 1))
94 bd.add_optimizer_state(os)
95 
96 # actually optimize things
97 print "running"
98 bd.optimize(steps)
99 
100 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
void optimize_balls(const kernel::ParticlesTemp &ps, const kernel::RestraintsTemp &rs=kernel::RestraintsTemp(), const PairPredicates &excluded=PairPredicates(), const OptimizerStates &opt_states=OptimizerStates(), base::LogLevel ll=base::DEFAULT)
Score particles based on how far outside a box they are.
Vector3D get_random_vector_in(const Cylinder3D &c)
Generate a random vector in a cylinder with uniform density.
static XYZR setup_particle(kernel::Model *m, ParticleIndex pi)
Definition: XYZR.h:48
Simple Brownian dynamics optimizer.
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:45
See IMP.example for more information.
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:47
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
See IMP.display for more information.
Definition: BildWriter.h:20
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.