IMP logo
IMP Reference Guide  2.15.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 import sys
12 
13 IMP.setup_from_argv(sys.argv, "rigid body excluded volume")
14 
15 # create a rigid body per helix
16 
17 
18 def create_representation():
19  m = IMP.Model()
21  'helix_0.pdb'), m, IMP.atom.CAlphaPDBSelector())
23  'helix_1.pdb'), m, IMP.atom.CAlphaPDBSelector())
24  for h in [h0, h1]:
26  return (m, [h0, h1])
27 
28 
29 def create_excluded_volume(m, helices):
30  # this is the interesting function:
31  # it uses a KClosePairsPair score to generate the list of close atoms on
32  # the fly
33  all = []
34  for h in helices:
35  all.extend(IMP.atom.get_by_type(h, IMP.atom.ATOM_TYPE))
38  evr.set_maximum_score(.01)
39  return [evr]
40 
41 
42 # creating the discrete states for domino
43 def create_discrete_states(m, helices):
46  IMP.algebra.Vector3D(0, 1, 0), math.pi / 2.0)
47  trs = []
48  zv = IMP.algebra.Vector3D(0, 0, 0)
50  IMP.algebra.Transformation3D(rot00, zv)))
51  for dx in range(0, 15):
52  tr = IMP.algebra.Vector3D(1.0 * dx, 0, 0)
54  IMP.algebra.Transformation3D(rot00, tr)))
55  pstate = IMP.domino.RigidBodyStates(trs)
56  for h in helices:
57  pst.set_particle_states(
58  IMP.core.RigidMember(h).get_rigid_body(), pstate)
59  return pst
60 
61 # setting up domino (and filters)
62 
63 
64 def create_sampler(m, rs, pst):
65  s = IMP.domino.DominoSampler(m, pst)
66  s.set_restraints(rs)
67  filters = []
68  # do not allow particles with the same ParticleStates object
69  # to have the same state index
70  filters.append(IMP.domino.ExclusionSubsetFilterTable(pst))
72  rc.add_restraints(rs)
73  # filter states that score worse than the cutoffs in the Model
75  states = IMP.domino.BranchAndBoundAssignmentsTable(pst, filters)
76  s.set_assignments_table(states)
77  s.set_subset_filter_tables(filters)
78  return s
79 
80 
81 def display(m, helices, name):
82  m.update()
83  w = IMP.display.PymolWriter(name)
84  for i, h in enumerate(helices):
86  g.set_color(IMP.display.get_display_color(i))
87  w.add_geometry(g)
88 
89 IMP.set_log_level(IMP.SILENT)
90 print("creating representation")
91 (m, helices) = create_representation()
92 
93 print("creating score function")
94 rs = create_excluded_volume(m, helices)
95 
96 print("creating discrete states")
97 pst = create_discrete_states(m, helices)
98 
99 print("creating sampler")
100 s = create_sampler(m, rs, pst)
101 m.set_log_level(IMP.SILENT)
102 IMP.set_log_level(IMP.VERBOSE)
103 print("sampling")
104 cs = s.create_sample()
105 
106 print("found ", cs.get_number_of_configurations(), "solutions")
107 score = []
109 for i in range(cs.get_number_of_configurations()):
110  cs.load_configuration(i)
111  ss = sf.evaluate(False)
112  score.append(ss)
113  print("** solution number:", i, " is:", ss)
114  display(m, helices, "sol_" + str(i) + ".pym")
Simple 3D transformation class.
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
Sample best solutions using Domino.
Definition: DominoSampler.h:32
Filter a configuration of the subset using the Model thresholds.
Create a scoring function on a list of restraints.
void read_pdb(TextInput input, int model, Hierarchy h)
Restraint * create_excluded_volume(Model *m, const ParticleIndexes &ps, double k, std::string name)
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.
Definition: Rotation3D.h:421
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
Do not allow two particles to be in the same state.
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
Store a list of ParticleIndexes.
Color get_display_color(unsigned int i)
void set_log_level(LogLevel l)
Set the current global log level.
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:421
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:77
Functionality for loading, creating, manipulating and scoring atomic structures.
Divide-and-conquer inferential optimization in discrete space.
Display an IMP::atom::Hierarchy particle as balls.