IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
cube.py
1## \example em/cube.py
2# The example creates a simple mrc file that is filled uniformly with 1s.
3# In addition, an RMF file is written with a marker at each corner of the
4# density. When both files are opened (e.g. in Chimera), the density should
5# be centered among the markers. This can be used for testing for
6# registration errors when reading and writing density maps.
7
8import IMP.em
9import IMP.display
10import IMP.rmf
11import RMF
12import sys
13
14IMP.setup_from_argv(sys.argv, "cube")
15
17 IMP.algebra.Vector3D(11, 11, 11))
18dm = IMP.em.create_density_map(bb, 2.5)
20print(dmbb, bb)
21
22for i in range(0, dm.get_number_of_voxels()):
23 dm.set_value(i, 1)
24
25nm = IMP.create_temporary_file_name("cube", ".mrc")
26print(nm)
27IMP.em.write_map(dm, nm)
28
29nm = IMP.create_temporary_file_name("cube", ".rmf")
30print(nm)
31w = RMF.create_rmf_file(nm)
32
33for v in IMP.algebra.get_vertices(bb):
36IMP.rmf.save_frame(w, "zero")
void write_map(DensityMap *m, std::string filename, MapReaderWriter *writer)
Write a density map to a file using the given writer.
VectorD< 3 > Vector3D
Definition VectorD.h:407
Vector< VectorD< D > > get_vertices(const BoundingBoxD< D > &bb)
Return a list of the 2^D bounding points for the bounding box.
Output IMP model data in various file formats.
Basic utilities for handling cryo-electron microscopy 3D density maps.
algebra::BoundingBoxD< 3 > get_bounding_box(const DensityMap *m, Float threshold)
Get the bounding box for a map.
DensityMap * create_density_map(const DensityMap *other)
Create a copy of another map.
Support for the RMF file format for storing hierarchical molecular data and markup.
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.
std::string create_temporary_file_name(std::string prefix="imp_temp", std::string suffix="")
Create a temporary file.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.