IMP  2.4.0
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 from __future__ import print_function
9 import IMP.atom
10 import IMP.rmf
11 import RMF
12 m = IMP.kernel.Model()
13 
14 # Create a new IMP.atom.Hierarchy from the contents of the pdb file
15 h = IMP.atom.read_pdb(IMP.rmf.get_example_path("simple.pdb"), m)
16 
17 # find the name for a temporary file to use to for writing the hdf5 file
18 tfn = IMP.create_temporary_file_name("link", ".rmf")
19 
20 print("File name is", tfn)
21 
22 # open the temporary file, clearing any existing contents
23 rh = RMF.create_rmf_file(tfn)
24 
25 # add the hierarchy to the file
27 
28 # add the current configuration to the file as frame 0
30 
31 # close the file
32 del rh
33 
34 # reopen it, don't clear the file when opening it
35 rh = RMF.open_rmf_file_read_only(tfn)
36 
37 # link to the existing pdb hierarchy
39 
40 # load the same coordinates in, ok, that is not very exciting
41 IMP.rmf.load_frame(rh, RMF.FrameID(0))
42 
43 print("Try running hdf5_display or hdf5_show on", tfn)
void save_frame(RMF::FileHandle file, unsigned int, std::string name="")
Definition: frames.h:42
void load_frame(RMF::FileConstHandle file, unsigned int frame)
Definition: frames.h:27
void add_hierarchies(RMF::NodeHandle fh, const atom::Hierarchies &hs)
void link_hierarchies(RMF::FileConstHandle fh, const atom::Hierarchies &hs)
Functionality for loading, creating, manipulating and scoring atomic structures.
void read_pdb(base::TextInput input, int model, Hierarchy h)
Support for the RMF file format for storing hierarchical molecular data and markup.
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.
Definition: kernel/Model.h:73