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