IMP  2.4.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 from __future__ import print_function
6 import IMP
7 import IMP.atom
8 import IMP.em
10 # 1. read a protein and get its bounding box dimension
12 # read protein
13 mh = IMP.atom.read_pdb(IMP.em.get_example_path("input.pdb"), m, sel)
14 apix = 1.
15 resolution = 6.
16 # compute bbox, and map size in voxels
18 #diag = bbox.get_corner(0) - bbox.get_corner(1)
19 #nx = int(bboxCoverage * diag[0] / apix)
20 #ny = int(bboxCoverage * diag[1] / apix)
21 #nz = int(bboxCoverage * diag[2] / apix)
22 
23 # create a density header of the requested size
24 dheader = IMP.em.create_density_header(bbox, apix)
25 dheader.set_resolution(resolution)
26 dmap = IMP.em.SampledDensityMap(dheader)
27 ps = IMP.core.get_leaves(mh)
28 dmap.set_particles(ps)
29 # dmap.get_header_writable().set_number_of_voxels(nx,ny,nz)
30 dmap.resample()
31 dmap.calcRMS()
32  # computes statistic stuff about the map and insert it in the
33  # header
34 print(dmap.get_header().show(), "\n")
35 IMP.em.write_map(dmap, "map.mrc", IMP.em.MRCReaderWriter())