IMP  2.1.1
The Integrative Modeling Platform
link.py
1 ## \example rmf/link.py
2 # This example is like module/rmf/pdb.py except that instead of creating a
3 # new hierarchy from the rmf file, it simply links the existing hierarchy
4 # to the file. This mechanism can be used for loading multiple
5 # conformations for scoring or other analysis without having to set up
6 # restraints and things each time.
7 
8 import IMP.atom
9 import IMP.rmf
10 import RMF
11 m = IMP.kernel.Model()
12 
13 # Create a new IMP.atom.Hierarchy from the contents of the pdb file
14 h = IMP.atom.read_pdb(IMP.rmf.get_example_path("simple.pdb"), m)
15 
16 # find the name for a temporary file to use to for writing the hdf5 file
17 tfn = IMP.create_temporary_file_name("link", ".rmf")
18 
19 print "File name is", tfn
20 
21 # open the temporary file, clearing any existing contents
22 rh = RMF.create_rmf_file(tfn)
23 
24 # add the hierarchy to the file
26 
27 # add the current configuration to the file as frame 0
28 IMP.rmf.save_frame(rh, 0)
29 
30 # close the file
31 del rh
32 
33 # reopen it, don't clear the file when opening it
34 rh = RMF.open_rmf_file(tfn)
35 
36 # link to the existing pdb hierarchy
38 
39 # load the same coordinates in, ok, that is not very exciting
40 IMP.rmf.load_frame(rh, 0)
41 
42 print "Try running hdf5_display or hdf5_show on", tfn
void save_frame(RMF::FileHandle file, int frame, std::string name="frame")
void add_hierarchies(RMF::NodeHandle fh, const atom::Hierarchies &hs)
void link_hierarchies(RMF::FileConstHandle fh, const atom::Hierarchies &hs)
See IMP.atom for more information.
void read_pdb(base::TextInput input, int model, Hierarchy h)
See IMP.rmf for more information.
Definition: associations.h:20
void load_frame(RMF::FileConstHandle file, int frame)
std::string get_example_path(std::string file_name)
Return the path to installed example data for this module.
Class for storing model, its restraints, constraints, and particles.