IMP  2.0.0
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(IMP.restrainer.get_example_path('input/eg2_representation.xml'))
23 rsr = restrainer.add_restraint(IMP.restrainer.get_example_path('input/eg2_restraint.xml'))
24 
25 ###=======================================================================###
26 # At this point all data from XML files have been placed into the model.
27 # Now it is possible to perform various operations on the IMP model.
28 ###=======================================================================###
29 
30 # Get the IMP model object used by restrainer
31 model = restrainer.get_model()
32 
33 # Find the IMP data structure with the given id
34 protein1_hierarchy = rep.get_imp_hierarchy_by_id('Protein1')
35 
36 # Get root hierarchy
37 root_hierarchy = rep.get_root_imp_hierarchy()
38 
39 # Get the rigid body with the given id
40 protein1_rb = rsr.get_rigid_body_by_id ("Protein1")
41 
42 # Get all rigid bodies
43 rbs = rsr.get_all_rigid_bodies()
44 
45 # Define transformation
46 ub = IMP.algebra.Vector3D(-50.0,-50.0,-50.0)
47 lb = IMP.algebra.Vector3D( 50.0, 50.0, 50.0)
48 bb = IMP.algebra.BoundingBox3D(ub, lb)
49 translation = IMP.algebra.get_random_vector_in(bb)
51 transformation = IMP.algebra.Transformation3D(rotation, translation)
52 
53 # Perform geometric transformations on the Protein1 rigid body
54 protein1_rb.set_reference_frame(IMP.algebra.ReferenceFrame3D(transformation))
55 protein1_rb.show()