IMP logo
IMP Reference Guide  2.22.0
The Integrative Modeling Platform
em/generate_density_map_of_fixed_dimension.py

Shows how to generate a density map of fixed dimension and how to sample particles within this density map.

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 
5 import IMP
6 import IMP.atom
7 import IMP.em
8 import sys
9 
10 IMP.setup_from_argv(sys.argv, "generate a density map of fixed dimension")
11 
12 m = IMP.Model()
13 # 1. read a protein and get its bounding box dimension
15 # read protein
16 mh = IMP.atom.read_pdb(IMP.em.get_example_path("input.pdb"), m, sel)
17 apix = 1.
18 resolution = 6.
19 # compute bbox, and map size in voxels
20 bbox = IMP.atom.get_bounding_box(mh)
21 
22 # create a density header of the requested size
23 dheader = IMP.em.create_density_header(bbox, apix)
24 dheader.set_resolution(resolution)
25 dmap = IMP.em.SampledDensityMap(dheader)
26 ps = IMP.core.get_leaves(mh)
27 dmap.set_particles(ps)
28 # dmap.get_header_writable().set_number_of_voxels(nx,ny,nz)
29 dmap.resample()
30 # computes statistic stuff about the map and insert it in the
31 # header
32 dmap.calcRMS()
33 print(dmap.get_header().show(), "\n")
34 IMP.em.write_map(dmap, "map.mrc", IMP.em.MRCReaderWriter())