IMP  2.1.0
The Integrative Modeling Platform
restrainer/em_restraint.py

This example shows how to use IMP::em::FitRestraint.

<!-- File: em_representation.xml -->
<Representation>
<Protein id="Protein1">
<Chain>
<Fragment id="frag1">
<GeometricShapeRep>
<Sphere radius="1.0" weight="1.0">
<InitialPosition optimize="1" x="12.0" y="12.0" z="12.0"/>
</Sphere>
</GeometricShapeRep>
</Fragment>
<Fragment id="frag2">
<GeometricShapeRep>
<Sphere radius="1.0" weight="1.0">
<InitialPosition optimize="1" x="15.0" y="6.0" z="6.0"/>
</Sphere>
</GeometricShapeRep>
</Fragment>
<Fragment id="frag3">
<GeometricShapeRep>
<Sphere radius="1.0" weight="1.0">
<InitialPosition optimize="1" x="6.0" y="15.0" z="15.0"/>
</Sphere>
</GeometricShapeRep>
</Fragment>
</Chain>
</Protein>
</Representation>
<!-- File: em_restraint.xml -->
<EM>
<Restraint name="em_restraint" density_filename="data/in.mrc" spacing="1.0" resolution="3.0" xorigin="-6.0" yorigin="-6.0" zorigin="-6.0">
<Particle id="frag1"/>
<Particle id="frag2"/>
<Particle id="frag3"/>
</EM>
1 ## \example restrainer/em_restraint.py
2 # This example shows how to use IMP::em::FitRestraint.
3 #
4 # \include em_representation.xml
5 # \include em_restraint.xml
6 #
7 
8 # -- File: em_restraint.py --#
9 
10 import IMP
11 import IMP.restrainer
12 
13 # Create restrainer object
14 restrainer = IMP.restrainer.Main()
15 
16 # Add representation and restraint to restrainer
17 rep = restrainer.add_representation(
18  IMP.restrainer.get_example_path('input/em_representation.xml'))
19 rsr = restrainer.add_restraint(
20  IMP.restrainer.get_example_path('input/em_restraint.xml'))
21 
22 # =======================================================================###
23 # At this point all data from XML files have been placed into the model.
24 # Now it is possible to perform various operations on the IMP model.
25 # =======================================================================###
26 
27 # Get the IMP model object used by restrainer
28 model = restrainer.get_model()
29 
30 # Get restraint by name
31 r = rsr.get_restraint_by_name('em_restraint')
32 
33 # Get EM density map header from the restraint
34 dmap_header = r.dmap_header
35 
36 # Get IMP::em::FitRestraint
37 fit_restraint = r.imp_restraint
38 fit_restraint.evaluate(False)