IMP  2.2.0
The Integrative Modeling Platform
pdb.py
1 ## \example rmf/pdb.py
2 # Write a PDB to an hdf5 file.
3 #
4 
5 import IMP.atom
6 import IMP.rmf
7 import RMF
9 
10 # Create a new IMP.atom.Hierarchy from the contents of the pdb file
11 h = IMP.atom.read_pdb(IMP.rmf.get_example_path("simple.pdb"), m)
12 
13 # find the name for a temporary file to use to for writing the hdf5 file
14 tfn = IMP.create_temporary_file_name("pdb", ".rmf")
15 
16 print "File name is", tfn
17 
18 # open the temporary file, clearing any existing contents
19 rh = RMF.create_rmf_file(tfn)
20 
21 # add the hierarchy to the file
23 
24 # add the current configuration to the file as frame 0
26 
27 # change a coordinate
28 IMP.core.XYZ(IMP.atom.get_leaves(h)[0]).set_x(0)
29 
30 # add the new configuration to the file as frame 1
32 
33 # close the file
34 del rh
35 
36 # reopen it, don't clear the file when opening it
37 rh = RMF.open_rmf_file_read_only(tfn)
38 
39 # hps is a list with one element which is a copy of h
40 hps = IMP.rmf.create_hierarchies(rh, m)
41 
42 IMP.atom.show_molecular_hierarchy(hps[0])
43 
44 # load the second configuration into hps
45 IMP.rmf.load_frame(rh, RMF.FrameID(0))
46 
47 print "Try running hdf5_display or hdf5_show on", tfn
atom::Hierarchies create_hierarchies(RMF::FileConstHandle fh, kernel::Model *m)
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
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
void add_hierarchies(RMF::NodeHandle fh, const atom::Hierarchies &hs)
See IMP.atom for more information.
void read_pdb(base::TextInput input, int model, Hierarchy h)
Hierarchies get_leaves(const Selection &h)
See IMP.rmf for more information.
Definition: associations.h:20
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:72