IMP  2.3.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_maximum_score(.01)
36  return [evr]
37 
38 
39 # creating the discrete states for domino
40 def create_discrete_states(m, helices):
43  IMP.algebra.Vector3D(0, 1, 0), math.pi / 2.0)
44  trs = []
45  zv = IMP.algebra.Vector3D(0, 0, 0)
47  IMP.algebra.Transformation3D(rot00, zv)))
48  for dx in range(0, 15):
49  tr = IMP.algebra.Vector3D(1.0 * dx, 0, 0)
51  IMP.algebra.Transformation3D(rot00, tr)))
52  pstate = IMP.domino.RigidBodyStates(trs)
53  for h in helices:
54  pst.set_particle_states(
55  IMP.core.RigidMember(h).get_rigid_body(), pstate)
56  return pst
57 
58 # setting up domino (and filters)
59 
60 
61 def create_sampler(m, rs, pst):
62  s = IMP.domino.DominoSampler(m, pst)
63  filters = []
64  # do not allow particles with the same ParticleStates object
65  # to have the same state index
66  filters.append(IMP.domino.ExclusionSubsetFilterTable(pst))
68  rc.add_restraints(rs)
69  # filter states that score worse than the cutoffs in the Model
71  states = IMP.domino.BranchAndBoundAssignmentsTable(pst, filters)
72  s.set_assignments_table(states)
73  s.set_subset_filter_tables(filters)
74  return s
75 
76 
77 def display(m, helices, name):
78  m.update()
79  w = IMP.display.PymolWriter(name)
80  for i, h in enumerate(helices):
82  g.set_color(IMP.display.get_display_color(i))
83  w.add_geometry(g)
84 
85 IMP.base.set_log_level(IMP.base.SILENT)
86 print "creating representation"
87 (m, helices) = create_representation()
88 
89 print "creating score function"
90 rs = create_excluded_volume(m, helices)
91 
92 print "creating discrete states"
93 pst = create_discrete_states(m, helices)
94 
95 print "creating sampler"
96 s = create_sampler(m, rs, pst)
97 m.set_log_level(IMP.base.SILENT)
98 IMP.base.set_log_level(IMP.base.VERBOSE)
99 print "sampling"
100 cs = s.create_sample()
101 
102 print "found ", cs.get_number_of_configurations(), "solutions"
103 score = []
104 for i in range(cs.get_number_of_configurations()):
105  cs.load_configuration(i)
106  ss = m.evaluate(False)
107  score.append(ss)
108  print "** solution number:", i, " is:", ss
109  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
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.
Store a kernel::ParticleIndexes.
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)
Basic functionality that is expected to be used by a wide variety of IMP users.
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
VectorD< 3 > Vector3D
Definition: VectorD.h:395
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
Functionality for loading, creating, manipulating and scoring atomic structures.
void read_pdb(base::TextInput input, int model, Hierarchy h)
Divide-and-conquer inferential optimization in discrete space.
Display an IMP::atom::Hierarchy particle as balls.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73