IMP logo
IMP Reference Guide  2.20.2
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 
8 from __future__ import print_function
9 import IMP.atom
10 import IMP.rmf
11 import RMF
12 import sys
13 
14 IMP.setup_from_argv(sys.argv, "link")
15 
16 m = IMP.Model()
17 
18 # Create a new IMP.atom.Hierarchy from the contents of the pdb file
19 h = IMP.atom.read_pdb(IMP.rmf.get_example_path("simple.pdb"), m)
20 
21 tfn = "link.rmf"
22 
23 print("File name is", tfn)
24 
25 # open the file, clearing any existing contents
26 rh = RMF.create_rmf_file(tfn)
27 
28 # add the hierarchy to the file
30 
31 # add the current configuration to the file as frame 0
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 # link to the existing pdb hierarchy
42 
43 # load the same coordinates in, ok, that is not very exciting
44 IMP.rmf.load_frame(rh, RMF.FrameID(0))
45 
46 print("Try running rmf_display or rmf_show on", tfn)
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.
void add_hierarchies(RMF::NodeHandle fh, const atom::Hierarchies &hs)
void link_hierarchies(RMF::FileConstHandle fh, const atom::Hierarchies &hs)
Functionality for loading, creating, manipulating and scoring atomic structures.
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.