IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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
5import IMP.display
6import IMP.rmf
7import RMF
8import sys
9
10IMP.setup_from_argv(sys.argv, "geometry")
11
12tfn = "rmf_geometry.rmf"
13
14# open the RMF, clearing any existing contents
15f = RMF.create_rmf_file(tfn)
16
17# creating a box geometry
19 IMP.algebra.Vector3D(10, 10, 10))
21
22# add the geometry to the file
24IMP.rmf.save_frame(f, "zero")
25
27 IMP.algebra.Vector3D(10, 10, 10))
28g.set_geometry(bb)
29# save a second frame with the bounding box
30IMP.rmf.save_frame(f, "one")
31
32
33del f
34f = RMF.open_rmf_file_read_only(tfn)
35# recreate the geometries from the file. The geometry will be the same
36# but it will not be a IMP.display.BoundingBoxGeometry; it will be
37# a set of cylinders instead.
39IMP.rmf.load_frame(f, RMF.FrameID(0))
40print(gs[0].get_name())
41print("Try running rmf_display on", tfn)
42
43# load another frame
44IMP.rmf.load_frame(f, RMF.FrameID(1))
45# cast it to a BoundingBoxGeometry and print out the geometry
46print(IMP.display.BoundingBoxGeometry.get_from(gs[0]).get_geometry())
VectorD< 3 > Vector3D
Definition VectorD.h:407
Output IMP model data in various file formats.
Support for the RMF file format for storing hierarchical molecular data and markup.
void load_frame(RMF::FileConstHandle file, RMF::FrameID frame)
Load the given RMF frame into the state of the linked objects.
void add_geometry(RMF::FileHandle file, display::Geometry *r)
Add a single geometry to 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.
display::Geometries create_geometries(RMF::FileConstHandle parent)
Create geometry objects for the geometry nodes found in the file.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.