IMP  2.0.1
The Integrative Modeling Platform
rmf/link.py

This example is like module/rmf/pdb.py except that instead of creating a new hierarchy from the rmf file, it simply links the existing hierarchy to the file. This mechanism can be used for loading multiple conformations for scoring or other analysis without having to set up restraints and things each time.

1 ## \example rmf/link.py
2 ## This example is like module/rmf/pdb.py except that instead of creating a new hierarchy from the rmf file, it simply links the existing hierarchy to the file. This mechanism can be used for loading multiple conformations for scoring or other analysis without having to set up restraints and things each time.
3 
4 import IMP.atom
5 import IMP.rmf
6 import RMF
7 m= IMP.Model()
8 
9 # Create a new IMP.atom.Hierarchy from the contents of the pdb file
11 
12 # find the name for a temporary file to use to for writing the hdf5 file
13 tfn=IMP.create_temporary_file_name("link", ".rmf")
14 
15 print "File name is", tfn
16 
17 # open the temporary file, clearing any existing contents
18 rh = RMF.create_rmf_file(tfn)
19 
20 # add the hierarchy to the file
22 
23 # add the current configuration to the file as frame 0
24 IMP.rmf.save_frame(rh, 0)
25 
26 # close the file
27 del rh
28 
29 # reopen it, don't clear the file when opening it
30 rh= RMF.open_rmf_file(tfn)
31 
32 # link to the existing pdb hierarchy
34 
35 # load the same coordinates in, ok, that is not very exciting
36 IMP.rmf.load_frame(rh, 0)
37 
38 print "Try running hdf5_display or hdf5_show on", tfn