IMP logo
IMP Reference Guide  develop.d97d4ead1f,2024/11/21
The Integrative Modeling Platform
rmf/link.py

This example is like module/rmf/pdb.py except that instead of creating a new hierarchy from the rmf file, it simply links the existing hierarchy to the file. This mechanism can be used for loading multiple conformations for scoring or other analysis without having to set up restraints and things each time.

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 import IMP.atom
9 import IMP.rmf
10 import RMF
11 import sys
12 
13 IMP.setup_from_argv(sys.argv, "link")
14 
15 m = IMP.Model()
16 
17 # Create a new IMP.atom.Hierarchy from the contents of the pdb file
18 h = IMP.atom.read_pdb(IMP.rmf.get_example_path("simple.pdb"), m)
19 
20 tfn = "link.rmf"
21 
22 print("File name is", tfn)
23 
24 # open the file, clearing any existing contents
25 rh = 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
34 del rh
35 
36 # reopen it, don't clear the file when opening it
37 rh = 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
43 IMP.rmf.load_frame(rh, RMF.FrameID(0))
44 
45 print("Try running rmf_display or rmf_show on", tfn)