IMP logo
IMP Reference Guide  2.7.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
3 # particles within this density map.
4 
5 from __future__ import print_function
6 import IMP
7 import IMP.atom
8 import IMP.em
9 import sys
10 
11 IMP.setup_from_argv(sys.argv, "generate a density map of fixed dimension")
12 
13 m = IMP.Model()
14 # 1. read a protein and get its bounding box dimension
16 # read protein
17 mh = IMP.atom.read_pdb(IMP.em.get_example_path("input.pdb"), m, sel)
18 apix = 1.
19 resolution = 6.
20 # compute bbox, and map size in voxels
21 bbox = IMP.atom.get_bounding_box(mh)
22 #diag = bbox.get_corner(0) - bbox.get_corner(1)
23 #nx = int(bboxCoverage * diag[0] / apix)
24 #ny = int(bboxCoverage * diag[1] / apix)
25 #nz = int(bboxCoverage * diag[2] / apix)
26 
27 # create a density header of the requested size
28 dheader = IMP.em.create_density_header(bbox, apix)
29 dheader.set_resolution(resolution)
30 dmap = IMP.em.SampledDensityMap(dheader)
31 ps = IMP.core.get_leaves(mh)
32 dmap.set_particles(ps)
33 # dmap.get_header_writable().set_number_of_voxels(nx,ny,nz)
34 dmap.resample()
35 dmap.calcRMS()
36  # computes statistic stuff about the map and insert it in the
37  # header
38 print(dmap.get_header().show(), "\n")
39 IMP.em.write_map(dmap, "map.mrc", IMP.em.MRCReaderWriter())
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
GenericHierarchies get_leaves(Hierarchy mhd)
Get all the leaves of the bit of hierarchy.
void read_pdb(TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
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 in 3D.
Basic utilities for handling cryo-electron microscopy 3D density maps.
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
Select all CA ATOM records.
Definition: pdb.h:77
Functionality for loading, creating, manipulating and scoring atomic structures.