IMP
2.0.0
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
rmf/geometry.py
1
## \example rmf/geometry.py
2
## This example shows writting one piece of geometry to an hdf5 and then reading it back.
3
4
import
IMP.display
5
import
IMP.rmf
6
import
RMF
7
8
# create a temporary file
9
tfn= IMP.create_temporary_file_name(
"rmf_geometry"
,
".rmf"
)
10
11
# open the hdf5, clearing any existing contents
12
f= RMF.create_rmf_file(tfn)
13
14
# creating a box geometry
15
bb=
IMP.algebra.BoundingBox3D
(
IMP.algebra.Vector3D
(0,0,0),
16
IMP.algebra.Vector3D
(10, 10, 10))
17
g=
IMP.display.BoundingBoxGeometry
(bb)
18
19
# add the geometry to the file
20
IMP.rmf.add_geometry(f, g)
21
IMP.rmf.save_frame
(f, 0)
22
23
bb=
IMP.algebra.BoundingBox3D
(
IMP.algebra.Vector3D
(1,1,1),
24
IMP.algebra.Vector3D
(10, 10, 10))
25
g.set_geometry(bb)
26
# save a second frame with the bounding box
27
IMP.rmf.save_frame
(f, 1)
28
29
30
del f
31
f= RMF.open_rmf_file_read_only(tfn)
32
# recreate the geometries from the file. The geometry will be the same
33
# but it will not be a IMP.display.BoundingBoxGeometry, it will be
34
# a set of cylinders instead.
35
gs=
IMP.rmf.create_geometries
(f)
36
IMP.rmf.load_frame
(f, 0)
37
print
gs[0].get_name()
38
print
"Try running rmf_display on"
, tfn
39
40
# load another frame
41
IMP.rmf.load_frame
(f, 1)
42
# cast it to a BoundingBoxGeometry and print out the geometry
43
print
IMP.display.BoundingBoxGeometry.get_from(gs[0]).get_geometry()