IMP logo
IMP Reference Guide  2.6.2
The Integrative Modeling Platform
rmf/geometry.py
1 ## \example rmf/geometry.py
2 # This example shows writing one piece of geometry to an RMF file and then
3 # reading it back.
4 
5 from __future__ import print_function
6 import IMP.display
7 import IMP.rmf
8 import RMF
9 import sys
10 
11 IMP.setup_from_argv(sys.argv, "geometry")
12 
13 # create a temporary file
14 tfn = IMP.create_temporary_file_name("rmf_geometry", ".rmf")
15 
16 # open the hdf5, clearing any existing contents
17 f = RMF.create_rmf_file(tfn)
18 
19 # creating a box geometry
21  IMP.algebra.Vector3D(10, 10, 10))
23 
24 # add the geometry to the file
26 IMP.rmf.save_frame(f, "zero")
27 
29  IMP.algebra.Vector3D(10, 10, 10))
30 g.set_geometry(bb)
31 # save a second frame with the bounding box
32 IMP.rmf.save_frame(f, "one")
33 
34 
35 del f
36 f = RMF.open_rmf_file_read_only(tfn)
37 # recreate the geometries from the file. The geometry will be the same
38 # but it will not be a IMP.display.BoundingBoxGeometry; it will be
39 # a set of cylinders instead.
41 IMP.rmf.load_frame(f, RMF.FrameID(0))
42 print(gs[0].get_name())
43 print("Try running rmf_display on", tfn)
44 
45 # load another frame
46 IMP.rmf.load_frame(f, RMF.FrameID(1))
47 # cast it to a BoundingBoxGeometry and print out the geometry
48 print(IMP.display.BoundingBoxGeometry.get_from(gs[0]).get_geometry())
display::Geometries create_geometries(RMF::FileConstHandle parent)
Create geometry objects for the geometry nodes found in the file.
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 load_frame(RMF::FileConstHandle file, RMF::FrameID frame)
VectorD< 3 > Vector3D
Definition: VectorD.h:395
void add_geometry(RMF::FileHandle file, display::Geometry *r)
Add a single geometry to the file.
Output IMP model data in various file formats.
Support for the RMF file format for storing hierarchical molecular data and markup.
std::string create_temporary_file_name(std::string prefix="imp_temp", std::string suffix="")
Create a temporary file.