IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
pdb.py
1## \example rmf/pdb.py
2# Write a PDB to an RMF file.
3#
4
5import IMP.atom
6import IMP.rmf
7import RMF
8import sys
9
10IMP.setup_from_argv(sys.argv, "pdb")
11
12m = IMP.Model()
13
14# Create a new IMP.atom.Hierarchy from the contents of the pdb file
16
17tfn = "pdb.rmf"
18
19print("File name is", tfn)
20
21# open the file, clearing any existing contents
22rh = 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
32
33# add the new configuration to the file as frame 1
35
36# close the file
37del rh
38
39# reopen it, don't clear the file when opening it
40rh = RMF.open_rmf_file_read_only(tfn)
41
42# hps is a list with one element which is a copy of h
44
46
47# load the second configuration into hps
48IMP.rmf.load_frame(rh, RMF.FrameID(0))
49
50print("Try running rmf_display or rmf_show on", tfn)
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
A decorator for a particle with x,y,z coordinates.
Definition XYZ.h:30
Functionality for loading, creating, manipulating and scoring atomic structures.
Hierarchy read_pdb(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector(), bool select_first_model=true)
Read all the molecules in the first model of the PDB file.
void show_molecular_hierarchy(Hierarchy h)
Print out the molecular hierarchy.
Hierarchies get_leaves(const Selection &h)
Support for the RMF file format for storing hierarchical molecular data and markup.
atom::Hierarchies create_hierarchies(RMF::FileConstHandle fh, Model *m)
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
void load_frame(RMF::FileConstHandle file, RMF::FrameID frame)
Load the given RMF frame into the state of the linked objects.
RMF::FrameID save_frame(RMF::FileHandle file, std::string name="")
Save the current state of the linked objects as a new RMF frame.
void add_hierarchies(RMF::FileHandle fh, const atom::Hierarchies &hs)
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.