home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.20.0
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
version 2.20.0
rmf/pdb.py
Write a PDB to an RMF file.
1
## \example rmf/pdb.py
2
# Write a PDB to an RMF file.
3
#
4
5
from
__future__
import
print_function
6
import
IMP.atom
7
import
IMP.rmf
8
import
RMF
9
import
sys
10
11
IMP.setup_from_argv
(sys.argv,
"pdb"
)
12
13
m =
IMP.Model
()
14
15
# Create a new IMP.atom.Hierarchy from the contents of the pdb file
16
h =
IMP.atom.read_pdb
(
IMP.rmf.get_example_path
(
"simple.pdb"
), m)
17
18
tfn =
"pdb.rmf"
19
20
print(
"File name is"
, tfn)
21
22
# open the file, clearing any existing contents
23
rh = RMF.create_rmf_file(tfn)
24
25
# add the hierarchy to the file
26
IMP.rmf.add_hierarchies
(rh, [h])
27
28
# add the current configuration to the file as frame 0
29
IMP.rmf.save_frame
(rh)
30
31
# change a coordinate
32
IMP.core.XYZ
(
IMP.atom.get_leaves
(h)[0]).set_x(0)
33
34
# add the new configuration to the file as frame 1
35
IMP.rmf.save_frame
(rh)
36
37
# close the file
38
del rh
39
40
# reopen it, don't clear the file when opening it
41
rh = RMF.open_rmf_file_read_only(tfn)
42
43
# hps is a list with one element which is a copy of h
44
hps =
IMP.rmf.create_hierarchies
(rh, m)
45
46
IMP.atom.show_molecular_hierarchy
(hps[0])
47
48
# load the second configuration into hps
49
IMP.rmf.load_frame
(rh, RMF.FrameID(0))
50
51
print(
"Try running rmf_display or rmf_show on"
, tfn)