IMP  2.1.1
The Integrative Modeling Platform
rigid_body_and_excluded_volume_restraint.py
1 ## \example restrainer/rigid_body_and_excluded_volume_restraint.py
2 # This example shows how to use IMP::core::RigidBody and IMP::core::ExcludedVolumeRestraint. We will construct a molecular hierarchy consisting of five proteins, and then apply connectivity restraint obtained from yeast two-hybrid experimental data to these proteins. We will define these proteins as rigid bodies and apply excluded volume restraint to prevent these proteins from interpenetrating.
3 # On the following figure, we see an XML representation of the molecular hierarchy.
4 #
5 # \include eg2_representation.xml
6 #
7 # From restrainer's point of view, a Rigid Body is a special form of restraint. Therefore, to make some parts of the hierarchy rigid, suitable rigid body declarations should be placed in the restraint XML file.
8 #
9 # \include eg2_restraint.xml
10 #
11 #
12 
13 # -- File: rigid_body_and_excluded_volume_restraint.py --#
14 
15 import IMP
16 import IMP.restrainer
17 
18 # Create restrainer object
19 restrainer = IMP.restrainer.Main()
20 
21 # Add representation and restraint to restrainer
22 rep = restrainer.add_representation(
23  IMP.restrainer.get_example_path('input/eg2_representation.xml'))
24 rsr = restrainer.add_restraint(
25  IMP.restrainer.get_example_path('input/eg2_restraint.xml'))
26 
27 # =======================================================================###
28 # At this point all data from XML files have been placed into the model.
29 # Now it is possible to perform various operations on the IMP model.
30 # =======================================================================###
31 
32 # Get the IMP model object used by restrainer
33 model = restrainer.get_model()
34 
35 # Find the IMP data structure with the given id
36 protein1_hierarchy = rep.get_imp_hierarchy_by_id('Protein1')
37 
38 # Get root hierarchy
39 root_hierarchy = rep.get_root_imp_hierarchy()
40 
41 # Get the rigid body with the given id
42 protein1_rb = rsr.get_rigid_body_by_id("Protein1")
43 
44 # Get all rigid bodies
45 rbs = rsr.get_all_rigid_bodies()
46 
47 # Define transformation
48 ub = IMP.algebra.Vector3D(-50.0, -50.0, -50.0)
49 lb = IMP.algebra.Vector3D(50.0, 50.0, 50.0)
50 bb = IMP.algebra.BoundingBox3D(ub, lb)
51 translation = IMP.algebra.get_random_vector_in(bb)
53 transformation = IMP.algebra.Transformation3D(rotation, translation)
54 
55 # Perform geometric transformations on the Protein1 rigid body
56 protein1_rb.set_reference_frame(IMP.algebra.ReferenceFrame3D(transformation))
57 protein1_rb.show()
Simple 3D transformation class.
Rotation3D get_random_rotation_3d(const Rotation3D &center, double distance)
Pick a rotation at random near the provided one.
See IMP.restrainer for more information.
Vector3D get_random_vector_in(const Cylinder3D &c)
Generate a random vector in a cylinder with uniform density.
A reference frame in 3D.
std::string get_example_path(std::string file_name)
Return the path to installed example data for this module.