IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
generate_density_map_of_fixed_dimension.py
1## \example em/generate_density_map_of_fixed_dimension.py
2# Shows how to generate a density map of fixed dimension and how to sample
3# particles within this density map.
4
5import IMP
6import IMP.atom
7import IMP.em
8import sys
9
10IMP.setup_from_argv(sys.argv, "generate a density map of fixed dimension")
11
12m = IMP.Model()
13# 1. read a protein and get its bounding box dimension
15# read protein
16mh = IMP.atom.read_pdb(IMP.em.get_example_path("input.pdb"), m, sel)
17apix = 1.
18resolution = 6.
19# compute bbox, and map size in voxels
21
22# create a density header of the requested size
23dheader = IMP.em.create_density_header(bbox, apix)
24dheader.set_resolution(resolution)
25dmap = IMP.em.SampledDensityMap(dheader)
27dmap.set_particles(ps)
28# dmap.get_header_writable().set_number_of_voxels(nx,ny,nz)
29dmap.resample()
30# computes statistic stuff about the map and insert it in the
31# header
32dmap.calcRMS()
33print(dmap.get_header().show(), "\n")
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Select all CA ATOM records.
Definition pdb.h:148
algebra::BoundingBoxD< 3 > get_bounding_box(const Hierarchy &h)
Get a bounding box for the Hierarchy.
void write_map(DensityMap *m, std::string filename, MapReaderWriter *writer)
Write a density map to a file using the given writer.
Class for sampling a density map from particles.
Functionality for loading, creating, manipulating and scoring atomic structures.
Hierarchy read_pdb(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector(), bool select_first_model=true)
Read all the molecules in the first model of the PDB file.
GenericHierarchies get_leaves(Hierarchy mhd)
Get all the leaves of the bit of hierarchy.
Basic utilities for handling cryo-electron microscopy 3D density maps.
DensityHeader create_density_header(const algebra::BoundingBoxD< 3 > &bb, float spacing)
Create a header from a bounding box in 3D.
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.