IMP  2.1.0
The Integrative Modeling Platform
rigid_body_excluded_volume.py
1 ## \example domino/rigid_body_excluded_volume.py
2 # This example shows using two rigid bodies and doing excluded volume with
3 # them.
4 
5 import IMP
6 import IMP.core
7 import IMP.algebra
8 import IMP.domino
9 import IMP.atom
10 import math
11 
12 # create a rigid body per helix
13 
14 
15 def create_representation():
16  m = IMP.kernel.Model()
18  'helix_0.pdb'), m, IMP.atom.CAlphaPDBSelector())
20  'helix_1.pdb'), m, IMP.atom.CAlphaPDBSelector())
21  for h in [h0, h1]:
23  return (m, [h0, h1])
24 
25 
26 def create_excluded_volume(m, helices):
27  # this is the interesting function:
28  # it uses a KClosePairsPair score to generate the list of close atoms on
29  # the fly
30  all = []
31  for h in helices:
32  all.extend(IMP.atom.get_by_type(h, IMP.atom.ATOM_TYPE))
35  evr.set_model(m)
36  evr.set_maximum_score(.01)
37  return [evr]
38 
39 
40 # creating the discrete states for domino
41 def create_discrete_states(m, helices):
44  IMP.algebra.Vector3D(0, 1, 0), math.pi / 2.0)
45  trs = []
46  zv = IMP.algebra.Vector3D(0, 0, 0)
48  IMP.algebra.Transformation3D(rot00, zv)))
49  for dx in range(0, 15):
50  tr = IMP.algebra.Vector3D(1.0 * dx, 0, 0)
52  IMP.algebra.Transformation3D(rot00, tr)))
53  pstate = IMP.domino.RigidBodyStates(trs)
54  for h in helices:
55  pst.set_particle_states(
56  IMP.core.RigidMember(h).get_rigid_body(), pstate)
57  return pst
58 
59 # setting up domino (and filters)
60 
61 
62 def create_sampler(m, rs, pst):
63  s = IMP.domino.DominoSampler(m, pst)
64  filters = []
65  # do not allow particles with the same ParticleStates object
66  # to have the same state index
67  filters.append(IMP.domino.ExclusionSubsetFilterTable(pst))
69  rc.add_restraints(rs)
70  # filter states that score worse than the cutoffs in the Model
72  states = IMP.domino.BranchAndBoundAssignmentsTable(pst, filters)
73  s.set_assignments_table(states)
74  s.set_subset_filter_tables(filters)
75  return s
76 
77 
78 def display(m, helices, name):
79  m.update()
80  w = IMP.display.PymolWriter(name)
81  for i, h in enumerate(helices):
83  g.set_color(IMP.display.get_display_color(i))
84  w.add_geometry(g)
85 
86 IMP.base.set_log_level(IMP.base.SILENT)
87 print "creating representation"
88 (m, helices) = create_representation()
89 
90 print "creating score function"
91 rs = create_excluded_volume(m, helices)
92 
93 print "creating discrete states"
94 pst = create_discrete_states(m, helices)
95 
96 print "creating sampler"
97 s = create_sampler(m, rs, pst)
98 m.set_log_level(IMP.base.SILENT)
99 IMP.base.set_log_level(IMP.base.VERBOSE)
100 print "sampling"
101 cs = s.get_sample()
102 
103 print "found ", cs.get_number_of_configurations(), "solutions"
104 score = []
105 for i in range(cs.get_number_of_configurations()):
106  cs.load_configuration(i)
107  ss = m.evaluate(False)
108  score.append(ss)
109  print "** solution number:", i, " is:", ss
110  display(m, helices, "sol_" + str(i) + ".pym")
Simple 3D transformation class.
void set_log_level(LogLevel l)
Set the current global log level.
Sample best solutions using Domino.
Definition: DominoSampler.h:32
A decorator for a particle that is part of a rigid body.
Definition: rigid_bodies.h:349
Filter a configuration of the subset using the kernel::Model thresholds.
A reference frame in 3D.
Rotation3D get_rotation_about_axis(const Vector3D &axis, double angle)
Generate a Rotation3D object from a rotation around an axis.
Do not allow two particles to be in the same state.
std::string get_example_path(std::string file_name)
Return the path to installed example data for this module.
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
Color get_display_color(unsigned int i)
container::ClosePairContainer * create_excluded_volume(const kernel::ParticlesTemp &ps, double k, std::string name)
See IMP.core for more information.
See IMP.algebra for more information.
IMP::core::RigidBody create_rigid_body(Hierarchy h)
Prevent a set of particles and rigid bodies from inter-penetrating.
Write a CGO file with the geometry.
Definition: PymolWriter.h:34
Select all CA ATOM records.
Definition: pdb.h:76
See IMP.atom for more information.
void read_pdb(base::TextInput input, int model, Hierarchy h)
See IMP.domino for more information.
Definition: analysis.h:15
Display an IMP::atom::Hierarchy particle as balls.
Class for storing model, its restraints, constraints, and particles.