IMP  2.0.0
The Integrative Modeling Platform
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
16  IMP.algebra.Vector3D(10, 10, 10))
18 
19 # add the geometry to the file
20 IMP.rmf.add_geometry(f, g)
22 
24  IMP.algebra.Vector3D(10, 10, 10))
25 g.set_geometry(bb)
26 # save a second frame with the bounding box
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.
37 print gs[0].get_name()
38 print "Try running rmf_display on", tfn
39 
40 # load another frame
42 # cast it to a BoundingBoxGeometry and print out the geometry
43 print IMP.display.BoundingBoxGeometry.get_from(gs[0]).get_geometry()