IMP  2.0.1
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.

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(IMP.restrainer.get_example_path('input/display_representation.xml'))
23 disp = restrainer.add_display(IMP.restrainer.get_example_path('input/pdb_display.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 # Write initial display in Chimera format
31 restrainer.log.write('initial_display_in_chimera.py')
32 
33 # Get the IMP model object used by restrainer
34 model = restrainer.get_model()
35 
36 model.show()
37 model.evaluate(False)