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