IMP  2.2.1
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 
5 import IMP
6 import IMP.atom
7 import IMP.em
9 # 1. read a protein and get its bounding box dimension
11 # read protein
12 mh = IMP.atom.read_pdb(IMP.em.get_example_path("input.pdb"), m, sel)
13 apix = 1.
14 resolution = 6.
15 # compute bbox, and map size in voxels
17 #diag = bbox.get_corner(0) - bbox.get_corner(1)
18 #nx = int(bboxCoverage * diag[0] / apix)
19 #ny = int(bboxCoverage * diag[1] / apix)
20 #nz = int(bboxCoverage * diag[2] / apix)
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 dmap.calcRMS()
31  # computes statistic stuff about the map and insert it in the
32  # header
33 print dmap.get_header().show(), "\n"
34 IMP.em.write_map(dmap, "map.mrc", IMP.em.MRCReaderWriter())
algebra::BoundingBoxD< 3 > get_bounding_box(const Hierarchy &h)
Get a bounding box for the Hierarchy.
GenericHierarchies get_leaves(Hierarchy mhd)
Get all the leaves of the bit of hierarchy.
void write_map(DensityMap *m, std::string filename)
Class for sampling a density map from particles.
DensityHeader create_density_header(const algebra::BoundingBoxD< 3 > &bb, float spacing)
Create a header from a bounding box 3D.
See IMP.em for more information.
Definition: CoarseCC.h:23
std::string get_example_path(std::string file_name)
Return the path to installed example data for this module.
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
Select all CA ATOM records.
Definition: pdb.h:76
See IMP.atom for more information.
void read_pdb(base::TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72