IMP  2.1.0
The Integrative Modeling Platform
restrainer/basic_display.py

In case we would like to create Chimera logs storing optimization states, we can provide geometric definitions in a display XML file. These XML definitions form a basic interface to IMP::display module. Currently, the only geometric aspect that can be specified is color.

This example shows how to color the representation components and output display file in chimera format.

<!-- File: display_representation.xml -->
<Representation>
<Protein id="Protein1">
<Chain id="Chain1" filename="data/6lyz.pdb">
<Fragment id="Frag1"><AtomicRep start_residue="1" end_residue="10"/></Fragment>
<Fragment id="Frag2"><AtomicRep start_residue="11" end_residue="20"/></Fragment>
<Fragment id="Frag3"><AtomicRep start_residue="21" end_residue="30"/></Fragment>
<Fragment id="Frag4"><AtomicRep start_residue="31" end_residue="40"/></Fragment>
</Chain>
</Protein>
</Representation>
<!-- File: pdb_display.xml -->
<Display>
<Protein id="Protein1">
<Chain id="Chain1"><Color r="1" g="1" b="1"/>
<Fragment id="Frag1"><Color r="0" g="1" b="1"/></Fragment>
<Fragment id="Frag2"><Color r="1" g="0" b="1"/></Fragment>
<Fragment id="Frag3"><Color r="1" g="1" b="0"/></Fragment>
<Fragment id="Frag4"><Color r="1" g="0" b="0"/></Fragment>
</Chain>
</Protein>
</Display>

Loading a display XML file is similar to loading the representation and restraint XML definitions. Only particles mentioned in the display XML file will be present (this is useful if we only want to display some portion of an hierarchy). The arguments to the create_log are the representation and the file name template (this '%%03d' will be replaced by consecutive numbers if we do optimization). This log is intended to be added to an optimization by performing: optimization.add_optimizer_state(log)

1 ## \example restrainer/basic_display.py
2 # In case we would like to create Chimera logs storing optimization states, we can provide geometric definitions in a display XML file. These XML definitions form a basic interface to IMP::display module. Currently, the only geometric aspect that can be specified is color.
3 #
4 # This example shows how to color the representation components and output display file in chimera format.
5 #
6 # \include display_representation.xml
7 #
8 # \include pdb_display.xml
9 #
10 # Loading a display XML file is similar to loading the representation and restraint XML definitions. Only particles mentioned in the display XML file will be present (this is useful if we only want to display some portion of an hierarchy). The arguments to the create_log are the representation and the file name template (this '%%03d' will be replaced by consecutive numbers if we do optimization). This log is intended to be added to an optimization by performing: optimization.add_optimizer_state(log)
11 #
12 
13 # -- File: basic_display.py --#
14 
15 import IMP
16 import IMP.restrainer
17 
18 # Create restrainer object
19 restrainer = IMP.restrainer.Main()
20 
21 # Add representation and color definition to restrainer
22 rep = restrainer.add_representation(
23  IMP.restrainer.get_example_path('input/display_representation.xml'))
24 disp = restrainer.add_display(
25  IMP.restrainer.get_example_path('input/pdb_display.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 # Write initial display in Chimera format
33 restrainer.log.write('initial_display_in_chimera.py')
34 
35 # Get the IMP model object used by restrainer
36 model = restrainer.get_model()
37 
38 model.show()
39 model.evaluate(False)