IMP logo
IMP Reference Guide  2.5.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
9 import sys
10 
11 IMP.setup_from_argv(sys.argv, "pdb")
12 
13 m = IMP.Model()
14 
15 # Create a new IMP.atom.Hierarchy from the contents of the pdb file
16 h = IMP.atom.read_pdb(IMP.rmf.get_example_path("simple.pdb"), m)
17 
18 # find the name for a temporary file to use to for writing the hdf5 file
19 tfn = IMP.create_temporary_file_name("pdb", ".rmf")
20 
21 print("File name is", tfn)
22 
23 # open the temporary file, clearing any existing contents
24 rh = RMF.create_rmf_file(tfn)
25 
26 # add the hierarchy to the file
28 
29 # add the current configuration to the file as frame 0
31 
32 # change a coordinate
33 IMP.core.XYZ(IMP.atom.get_leaves(h)[0]).set_x(0)
34 
35 # add the new configuration to the file as frame 1
37 
38 # close the file
39 del rh
40 
41 # reopen it, don't clear the file when opening it
42 rh = RMF.open_rmf_file_read_only(tfn)
43 
44 # hps is a list with one element which is a copy of h
45 hps = IMP.rmf.create_hierarchies(rh, m)
46 
48 
49 # load the second configuration into hps
50 IMP.rmf.load_frame(rh, RMF.FrameID(0))
51 
52 print("Try running hdf5_display or hdf5_show on", tfn)
void show_molecular_hierarchy(Hierarchy h)
Print out the molecular hierarchy.
atom::Hierarchies create_hierarchies(RMF::FileConstHandle fh, Model *m)
RMF::FrameID save_frame(RMF::FileHandle file, std::string name="")
Save the current state of the linked objects as a new RMF frame.
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
void read_pdb(TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
void load_frame(RMF::FileConstHandle file, RMF::FrameID frame)
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.
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 full path to one of this module's example files.
std::string create_temporary_file_name(std::string prefix="imp_temp", std::string suffix="")
Create a temporary file.