IMP logo
IMP Reference Guide  2.22.0
The Integrative Modeling Platform
pdb.py
1 ## \example rmf/pdb.py
2 # Write a PDB to an RMF file.
3 #
4 
5 import IMP.atom
6 import IMP.rmf
7 import RMF
8 import sys
9 
10 IMP.setup_from_argv(sys.argv, "pdb")
11 
12 m = IMP.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 tfn = "pdb.rmf"
18 
19 print("File name is", tfn)
20 
21 # open the 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
29 
30 # change a coordinate
31 IMP.core.XYZ(IMP.atom.get_leaves(h)[0]).set_x(0)
32 
33 # add the new configuration to the file as frame 1
35 
36 # close the file
37 del rh
38 
39 # reopen it, don't clear the file when opening it
40 rh = RMF.open_rmf_file_read_only(tfn)
41 
42 # hps is a list with one element which is a copy of h
43 hps = IMP.rmf.create_hierarchies(rh, m)
44 
46 
47 # load the second configuration into hps
48 IMP.rmf.load_frame(rh, RMF.FrameID(0))
49 
50 print("Try running rmf_display or rmf_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:86
void load_frame(RMF::FileConstHandle file, RMF::FrameID frame)
Load the given RMF frame into the state of the linked objects.
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.