IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
link.py
1## \example rmf/link.py
2# This example is like module/rmf/pdb.py except that instead of creating a
3# new hierarchy from the rmf file, it simply links the existing hierarchy
4# to the file. This mechanism can be used for loading multiple
5# conformations for scoring or other analysis without having to set up
6# restraints and things each time.
7
8import IMP.atom
9import IMP.rmf
10import RMF
11import sys
12
13IMP.setup_from_argv(sys.argv, "link")
14
15m = IMP.Model()
16
17# Create a new IMP.atom.Hierarchy from the contents of the pdb file
19
20tfn = "link.rmf"
21
22print("File name is", tfn)
23
24# open the file, clearing any existing contents
25rh = RMF.create_rmf_file(tfn)
26
27# add the hierarchy to the file
29
30# add the current configuration to the file as frame 0
32
33# close the file
34del rh
35
36# reopen it, don't clear the file when opening it
37rh = RMF.open_rmf_file_read_only(tfn)
38
39# link to the existing pdb hierarchy
41
42# load the same coordinates in, ok, that is not very exciting
43IMP.rmf.load_frame(rh, RMF.FrameID(0))
44
45print("Try running rmf_display or rmf_show on", tfn)
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
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.
Support for the RMF file format for storing hierarchical molecular data and markup.
void link_hierarchies(RMF::FileConstHandle fh, const atom::Hierarchies &hs)
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.