densityGridTools
index


 
Tools to help create, manipulate and plot densityGrid.DensityGrid objects 
used to represent electron density maps, projections and atomic force height 
maps.

 
Functions
       
covarianceValues(map)
Return the principal components of the covariance matrix, sorted in 
order of largest to smallest.
create_DensityGrid(filename=None, slice=None, delta=None, verbose=False)
Read the specified EDM file. Supported formats are MRC, MRCS and CCP4. 
The slice argument can be used to specify a slice containing a 2D 
projection.
 
The optional delta argument will override the grid spacing members of the
returned DensityGrid object - i.e. xdelta, ydelta, and (for 3D maps only) 
zdelta.
mergedSlicesAsImage(dmap1, dmap2, imgFilename, sliceNum=0, offset=None, verbose=False)
Given two projections, given as sliceNum slices of dmap1 and dmap2 
arguments, create an output image named imgFilename in which dmap1 and
dmap2 are represented as the colors magenta and green, respectively. 
Regions in which the projections have the same (nonzero) value appear
white.
sliceAsImage(dmap, imgFilename, sliceNum=0, usePalette=False)
Given a densityGrid.DensityGrid object, write out the specified slice
(grid number in the z-dimension) to the specified file. File type is
determined by the suffix given in imgFilename.
sliceToBytes(dmap, sliceNum=0)
Given a densityGrid.DensityGrid object, return a tuple containing
(xsize,ysize,dataInBytes), with byte data corresponding to slice given by 
sliceNum. Normalized pixel intensity is computed as 
2558(sliceData -minVal) / (maxVal-minVal), where minVal and maxVal are 
the minimal and maximal values in the slice.
sliceToImage(dmap, sliceNum=0, usePalette=False)
Given a densityGrid.DensityGrid object, return a PIL.Image with
a grayscale image corresponding to slice given by sliceNum, as returned 
by sliceToBytes.
 
The optional usePalette argument can be set to produce a black,red->blue
colormapped image instead of a black->white intensity image.
trimDensityGrid(dmap, pad=0.5, sel='not pseudo', algorithm='rectangle', verbose=False)
Return a new DensityGrid object whose grid is a subregion of
the input atomic density map around atom coordinates specified by sel. In
this way the DensityGrid can be reduced in size.
 
Given the current atomic coordinates defined by sel (an atom selection
string or atomSel.AtomSel object) and an atomic density map, dmap
(a string with the filename path of a ccp4 or mrc file or, alternatively,
an atomDensity.DensityGrid instance), return a subregion of dmap
(an atomDensity.DensityGrid instance) around the coordinates.
 
The method used to determine the subregion is specified by the
algorithm argument: either "sphere", where the subregion is
defined by the smallest sphere (of radius r) that envelops all the
coordinates, with r augmented by the multiplier specified by the
pad argument (i.e., the sphere has a radius r + pad * r, centered
around the centroid of the coordinates). or "rectangle" whereby a
rectangular prism is selected using the same mechanism, but different
values are determined in each dimension. If the region exceeds the
dimensions of the map in one dimension, the map is truncated to
the bounds of the original map.