DENSS.denss.core

Contents

DENSS.denss.core#

B2u(B)#

Calculate atomic displacement, u, from B-factor

P2Rg(r, P)#
class PDB(filename=None, natoms=None, ignore_waters=True, chain=None)#

Bases: object

Load pdb file.

add_ImplicitH()#
calculate_distance_matrix(return_squareform=False)#
calculate_unique_volume(n=16, use_b=False, atomidx=None)#

Generate volumes and radii for each atom of a pdb by accounting for overlapping sphere volumes, i.e., each radius is set to the value that yields a volume of a sphere equal to the corrected volume of the sphere after subtracting spherical caps from bonded atoms.

generate_pdb_from_defaults(natoms)#
lookup_unique_volume()#
read_cif(filename, ignore_waters=True)#

Read a CIF file and load atom information.

Parameters:
  • filename – Path to the CIF file

  • chain_id – Optional chain ID to filter atoms (default: None, read all chains)

  • ignore_waters – Whether to ignore water molecules (default: True)

read_pdb(filename, ignore_waters=True, chain=None)#
remove_atomalt()#
remove_atoms_from_object(idx)#
remove_by_atomname(atomname)#
remove_by_atomnum(atomnum)#
remove_by_atomtype(atomtype)#
remove_by_chain(chain)#
remove_by_resname(resname)#
remove_by_resnum(resnum)#
remove_waters()#
write(filename)#

Write PDB file format using pdb object as input.

class PDB2MRC(pdb, ignore_waters=True, explicitH=True, modifiable_atom_types=None, center_coords=True, radii_sf=None, recalculate_atomic_volumes=False, exvol_type='gaussian', use_b=False, global_B=None, resolution=None, voxel=None, side=None, nsamples=None, rho0=None, shell_contrast=None, shell_mrcfile=None, shell_type='water', Icalc_interpolation=True, fit_scale=True, fit_offset=False, data_filename=None, data_units='a', n1=None, n2=None, qmin=None, qmax=None, nq=None, penalty_weight=1.0, penalty_weights=[1.0, 0.01], fit_rho0=True, fit_shell=True, fit_all=True, min_method='Nelder-Mead', min_opts='{"adaptive": True}', fast=False, use_sasrec_during_fitting=False, ignore_warnings=False, quiet=False, run_all_on_init=False, logger=None)#

Bases: object

calc_F_with_modified_params(params, full_qr=False)#

Calculates structure factor sum from set of parameters with optimized performance

calc_I_with_modified_params(params)#

Calculates intensity profile for optimization of parameters

calc_chi2()#
calc_penalty(params)#

Calculates a penalty using quadratic loss function for parameters dependent on a target value for each parameter.

calc_rho_with_modified_params(params)#

Calculates electron density map for protein in solution. Includes the excluded volume and hydration shell calculations.

calc_score_with_modified_params(params)#
calculate_average_radii()#
calculate_excluded_volume(quiet=False)#
calculate_excluded_volume_in_A3()#

Calculate the excluded volume of the particle in angstroms cubed.

calculate_global_B()#
calculate_hydration_shell()#
calculate_invacuo_density()#
calculate_structure_factors()#
initialize_penalties(penalty_weight=None)#

Initialize penalty weights more efficiently by avoiding redundant calculations

load_data(filename=None, Iq_exp=None, units=None)#
make_grids()#
minimize_parameters(fit_radii=False)#
run_all()#

Run all necessary steps to generate density maps, structure factors, and scattering profile using current settings.

save_Iq_calc(prefix=None, qmax=None, nq=None, qc=None, use_sasrec=True)#

Save the calculated Iq curve to a .dat file.

save_fit(prefix=None)#

Save the combined experimental and calculated Iq curve to a .fit file.

scale_radii(radii_sf=None)#

Scale all the modifiable atom type radii in the pdb

set_radii(atom_types, radii)#

For each atom type in atom_types, set its value to corresponding radius in radii.

class PDB2SAS(pdb, q=None, numba=True)#

Bases: object

Calculate the scattering of an object from a set of 3D coordinates using the Debye formula.

pdb - a saxstats PDB file object. q - q values to use for calculations (optional).

calc_I(numba=True)#
calc_debye(natoms_limit=1000)#

Calculate the scattering of an object from a set of 3D coordinates using the Debye formula.

calc_form_factors(B=0.0)#

Calculate the scattering of an object from a set of 3D coordinates using the Debye formula.

B - B-factors (i.e. Debye-Waller/temperature factors) of atoms (default=0.0)

class Sasrec(Iq, D, qc=None, r=None, nr=None, alpha=0.0, ne=2, extrapolate=True)#

Bases: object

Bt(q=None)#
Ct()#

Return the values of C, a m x n variance-covariance matrix

Ct2()#

Return the values of C, a m x n variance-covariance matrix while smoothing P(r)

Et()#

Calculate En function, for use in ravg calculation

Ft()#

Calculate Fn function, for use in Rg calculation

Gmn()#

Return the mxn matrix of coefficients for the integral of (2nd deriv of P(r))**2 used for smoothing

I0errf()#

Calculate error on I0 from Shannon intensities from inverse C variance-covariance matrix

Icerrt()#

Return the standard errors on I_c(q).

Ish2I0()#

Calculate I0 from Shannon intensities

Ish2Iq()#

Calculate I(q) from intensities at Shannon points.

Ish2P()#

Calculate P(r) from intensities at Shannon points.

Ish2Q()#

Calculate Porod Invariant Q from Shannon intensities

Ish2Qr()#

Calculate Rambo Invariant Qr (Vc^2/Rg) from Shannon intensities

Ish2Vc()#

Calculate Volume of Correlation from Shannon intensities

Ish2Vp()#

Calculate Porod Volume from Shannon intensities

Ish2avgr()#

Calculate average vector length r from Shannon intensities

Ish2lc()#

Calculate length of correlation from Shannon intensities

Ish2mwVc(RNA=False)#

Calculate molecular weight via the Volume of Correlation from Shannon intensities

Ish2mwVp()#

Calculate molecular weight via Porod Volume from Shannon intensities

Ish2rg()#

Calculate Rg from Shannon intensities

Perrt()#

Return the standard errors on P(r).

Qerrf()#

Calculate error on Q from Shannon intensities from inverse C variance-covariance matrix

St()#
Vcerrf()#

Calculate error on Vc from Shannon intensities from inverse C variance-covariance matrix

Vperrf()#

Calculate error on Vp from Shannon intensities from inverse C variance-covariance matrix

Yt()#

Return the values of Y, an m-length vector.

avgrerrf()#

Calculate error on Rg from Shannon intensities from inverse C variance-covariance matrix

calc_chi2()#
create_lowq()#

Create a calculated q range for Sasrec for low q out to q=0. Just the q values, not any extrapolation of intensities.

estimate_Vp_etal()#

Estimate Porod volume using modified method based on oversmoothing.

Oversmooth the P(r) curve with a high alpha. This helps to remove shape scattering that distorts Porod assumptions.

extrapolate()#

Extrapolate to high q values

gamma0()#

Calculate gamma at r=0. gamma is P(r)/4*pi*r^2

lcerrf()#

Calculate error on lc from Shannon intensities from inverse C variance-covariance matrix

mwVcerrf()#
mwVperrf()#

Calculate error on mwVp from Shannon intensities from inverse C variance-covariance matrix

optimize_alpha(gui=False)#

Scan alpha values to find optimal alpha

rgerrf()#

Calculate error on Rg from Shannon intensities from inverse C variance-covariance matrix

rgerrfold()#

Calculate error on Rg from Shannon intensities from inverse C variance-covariance matrix

shannon_channels(D, qmax=0.5, qmin=0.0)#

Return the number of Shannon channels given a q range and maximum particle dimension

update()#
abs2(x)#
abs2_fast(x, out=None)#
align(refrho, movrho, coarse=True, abort_event=None)#

Align second electron density map to the first.

align2xyz(rho, return_transform=False)#

Align rho such that principal axes align with XYZ axes.

align_multiple(refrho, rhos, cores=1, abort_event=None, single_proc=False)#

Align multiple (or a single) maps to the reference.

average_pairs(rhos, cores=1, abort_event=None, single_proc=False)#

Average pairs of electron density maps, second half to first half.

average_two(rho1, rho2, abort_event=None)#

Align two electron density maps and return the average.

binary_average(rhos, cores=1, abort_event=None, single_proc=False)#

Generate a reference electron density map using binary averaging.

calc_chi2(Iq_exp, Iq_calc, scale=True, offset=False, interpolation=True, return_sf=False, return_fit=False, use_sasrec=True, D=None)#

Calculates a chi2 comparing experimental vs calculated intensity profiles using interpolation.

Iq_exp (ndarray) - Experimental data, q, I, sigq (required) Iq_calc (ndarray) - calculated scattering profile’s q, I, and sigq (required) scale (bool) - whether to allow scaling of Iq_exp to Iq_calc offset (bool) - whether to allow offset of Iq_exp to Iq_calc interpolation (bool) - whether to allow fine interpolation of Icalc to qexp using cubic spline return_sf (bool) - return scale factor of Iq_exp return_fit (bool) - return fit formatted as Nx4 array of [qexp, c*Iexp+b, c*err, Icalc], where c,b are scale and offset

calc_fsc(rho1, rho2, side)#

Calculate the Fourier Shell Correlation between two electron density maps.

calc_rg_I0_by_guinier(Iq, nb=None, ne=None)#

calculate Rg, I(0) by fitting Guinier equation to data. Use only desired q range in input arrays.

calc_rg_by_guinier_first_2_points(q, I, DENSS_GPU=False)#

calculate Rg using Guinier law, but only use the first two data points. This is meant to be used with a calculated scattering profile, such as Imean from denss().

calc_rg_by_guinier_peak(Iq, exp=1, nb=0, ne=None)#

roughly estimate Rg using the Guinier peak method. Use only desired q range in input arrays. exp - the exponent in q^exp * I(q)

calc_rho0(mw, conc)#

Estimate bulk solvent density, rho0, from list of molecular weights and molar concentrations of components. mw and conc can be lists (nth element of mw corresponds to nth element of concentration) mw in g/mol concentration in mol/L.

calc_uniform_shell(pdb, x, y, z, thickness=2.8, distance=1.4)#

Create a uniform density hydration shell around the particle.

pdb - instance of PDB class (required) x,y,z - meshgrids for x, y, and z (required) thickness - thickness of the shell (e.g. water diameter) distance - distance from the protein surface defining the center of the shell (e.g., water radius)

cap_heights(r1, r2, d)#

Calculate the heights h1, h2 of spherical caps from overlapping spheres of radii r1, r2 a distance d apart

center_of_circle_from_sphere_intersection(x1, y1, z1, r1, x2, y2, z2, r2, a, b, c, d)#

Calculate the center of the circle formed by the intersection of two spheres

center_rho(rho, centering='com', return_shift=False, maxfirst=True, iterations=1)#

Move electron density map so its center of mass aligns with the center of the grid

centering - which part of the density to center on. By default, center on the

center of mass (“com”). Can also center on maximum density value (“max”).

center_rho_roll(rho, recenter_mode='com', maxfirst=True, return_shift=False)#

Move electron density map so its center of mass aligns with the center of the grid

rho - electron density array recenter_mode - a string either com (center of mass) or max (maximum density)

check_if_raw_data(Iq)#

Check if an I(q) profile is a smooth fitted profile, or raw data.

Iq - N x 3 numpy array, where N is the number of data points, and the

three columns are q, I, error.

This performs a very simple check. It simply checks if there exists a q = 0 term. The Iq profile given should be first cleaned up by clean_up_data() function, which will remove I=0 and sig=0 data points.

chi2(exp, calc, sig)#

Return the chi2 discrepancy between experimental and calculated data

clean_up_data(Iq)#

Do a quick cleanup by removing zero intensities and zero errors.

Iq - N x 3 numpy array, where N is the number of data points, and the three columns are q, I, error.

coarse_then_fine_alignment(refrho, movrho, coarse=True, topn=1, abort_event=None)#

Course alignment followed by fine alignment. Select the topn candidates from the grid search and minimize each, selecting the best fine alignment.

create_lowq(q)#

Create a calculated q range for Sasrec for low q out to q=0. Just the q values, not any extrapolation of intensities.

denss_3DFs(rho_start, dmax, ne=None, voxel=5.0, oversampling=3.0, positivity=True, output='map', steps=2001, seed=None, shrinkwrap=True, shrinkwrap_sigma_start=3, shrinkwrap_sigma_end=1.5, shrinkwrap_sigma_decay=0.99, shrinkwrap_threshold_fraction=0.2, shrinkwrap_iter=20, shrinkwrap_minstep=50, write_freq=100, support=None, enforce_connectivity=True, enforce_connectivity_steps=[6000], quiet=False)#

Calculate electron density from starting map by refining phases only.

direct_I2P(q, I, D=None)#
ecdf(x)#

convenience function for computing the empirical CDF

equation_of_plane_from_sphere_intersection(x1, y1, z1, r1, x2, y2, z2, r2)#

Calculate coefficients a,b,c,d of equation of a plane (ax+by+cz+d=0) formed by the intersection of two spheres with centers (x1,y1,z1), (x2,y2,z2) and radii r1,r2. from: http://ambrnet.com/TrigoCalc/Sphere/TwoSpheres/Intersection.htm

estimate_dmax(Iq, dmax=None, clean_up=True)#

Attempt to roughly estimate Dmax directly from data.

estimate_side_from_pdb(pdb, use_convex_hull=False)#
euler2matrix(alpha=0.0, beta=0.0, gamma=0.0)#

Convert Euler angles alpha, beta, gamma to a standard rotation matrix.

alpha - yaw, counterclockwise rotation about z-axis, upper-left quadrant beta - pitch, counterclockwise rotation about y-axis, four-corners gamma - roll, counterclockwise rotation about x-axis, lower-right quadrant all angles given in radians

Simple grid search on uniformly sampled sphere to optimize alignment. Return the topn candidate maps (default=1, i.e. the best candidate).

filter_P(r, P, sigr=None, qmax=0.5, cutoff=0.75, qmin=0.0, cutoffmin=1.25)#

Filter P(r) and sigr of oscillations.

find_nearest_i(array, value)#

Return the index of the array item nearest to specified value

formfactor(element, q=array([0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009, 0.01, 0.011, 0.012, 0.013, 0.014, 0.015, 0.016, 0.017, 0.018, 0.019, 0.02, 0.021, 0.022, 0.023, 0.024, 0.025, 0.026, 0.027, 0.028, 0.029, 0.03, 0.031, 0.032, 0.033, 0.034, 0.035, 0.036, 0.037, 0.038, 0.039, 0.04, 0.041, 0.042, 0.043, 0.044, 0.045, 0.046, 0.047, 0.048, 0.049, 0.05, 0.051, 0.052, 0.053, 0.054, 0.055, 0.056, 0.057, 0.058, 0.059, 0.06, 0.061, 0.062, 0.063, 0.064, 0.065, 0.066, 0.067, 0.068, 0.069, 0.07, 0.071, 0.072, 0.073, 0.074, 0.075, 0.076, 0.077, 0.078, 0.079, 0.08, 0.081, 0.082, 0.083, 0.084, 0.085, 0.086, 0.087, 0.088, 0.089, 0.09, 0.091, 0.092, 0.093, 0.094, 0.095, 0.096, 0.097, 0.098, 0.099, 0.1, 0.101, 0.102, 0.103, 0.104, 0.105, 0.106, 0.107, 0.108, 0.109, 0.11, 0.111, 0.112, 0.113, 0.114, 0.115, 0.116, 0.117, 0.118, 0.119, 0.12, 0.121, 0.122, 0.123, 0.124, 0.125, 0.126, 0.127, 0.128, 0.129, 0.13, 0.131, 0.132, 0.133, 0.134, 0.135, 0.136, 0.137, 0.138, 0.139, 0.14, 0.141, 0.142, 0.143, 0.144, 0.145, 0.146, 0.147, 0.148, 0.149, 0.15, 0.151, 0.152, 0.153, 0.154, 0.155, 0.156, 0.157, 0.158, 0.159, 0.16, 0.161, 0.162, 0.163, 0.164, 0.165, 0.166, 0.167, 0.168, 0.169, 0.17, 0.171, 0.172, 0.173, 0.174, 0.175, 0.176, 0.177, 0.178, 0.179, 0.18, 0.181, 0.182, 0.183, 0.184, 0.185, 0.186, 0.187, 0.188, 0.189, 0.19, 0.191, 0.192, 0.193, 0.194, 0.195, 0.196, 0.197, 0.198, 0.199, 0.2, 0.201, 0.202, 0.203, 0.204, 0.205, 0.206, 0.207, 0.208, 0.209, 0.21, 0.211, 0.212, 0.213, 0.214, 0.215, 0.216, 0.217, 0.218, 0.219, 0.22, 0.221, 0.222, 0.223, 0.224, 0.225, 0.226, 0.227, 0.228, 0.229, 0.23, 0.231, 0.232, 0.233, 0.234, 0.235, 0.236, 0.237, 0.238, 0.239, 0.24, 0.241, 0.242, 0.243, 0.244, 0.245, 0.246, 0.247, 0.248, 0.249, 0.25, 0.251, 0.252, 0.253, 0.254, 0.255, 0.256, 0.257, 0.258, 0.259, 0.26, 0.261, 0.262, 0.263, 0.264, 0.265, 0.266, 0.267, 0.268, 0.269, 0.27, 0.271, 0.272, 0.273, 0.274, 0.275, 0.276, 0.277, 0.278, 0.279, 0.28, 0.281, 0.282, 0.283, 0.284, 0.285, 0.286, 0.287, 0.288, 0.289, 0.29, 0.291, 0.292, 0.293, 0.294, 0.295, 0.296, 0.297, 0.298, 0.299, 0.3, 0.301, 0.302, 0.303, 0.304, 0.305, 0.306, 0.307, 0.308, 0.309, 0.31, 0.311, 0.312, 0.313, 0.314, 0.315, 0.316, 0.317, 0.318, 0.319, 0.32, 0.321, 0.322, 0.323, 0.324, 0.325, 0.326, 0.327, 0.328, 0.329, 0.33, 0.331, 0.332, 0.333, 0.334, 0.335, 0.336, 0.337, 0.338, 0.339, 0.34, 0.341, 0.342, 0.343, 0.344, 0.345, 0.346, 0.347, 0.348, 0.349, 0.35, 0.351, 0.352, 0.353, 0.354, 0.355, 0.356, 0.357, 0.358, 0.359, 0.36, 0.361, 0.362, 0.363, 0.364, 0.365, 0.366, 0.367, 0.368, 0.369, 0.37, 0.371, 0.372, 0.373, 0.374, 0.375, 0.376, 0.377, 0.378, 0.379, 0.38, 0.381, 0.382, 0.383, 0.384, 0.385, 0.386, 0.387, 0.388, 0.389, 0.39, 0.391, 0.392, 0.393, 0.394, 0.395, 0.396, 0.397, 0.398, 0.399, 0.4, 0.401, 0.402, 0.403, 0.404, 0.405, 0.406, 0.407, 0.408, 0.409, 0.41, 0.411, 0.412, 0.413, 0.414, 0.415, 0.416, 0.417, 0.418, 0.419, 0.42, 0.421, 0.422, 0.423, 0.424, 0.425, 0.426, 0.427, 0.428, 0.429, 0.43, 0.431, 0.432, 0.433, 0.434, 0.435, 0.436, 0.437, 0.438, 0.439, 0.44, 0.441, 0.442, 0.443, 0.444, 0.445, 0.446, 0.447, 0.448, 0.449, 0.45, 0.451, 0.452, 0.453, 0.454, 0.455, 0.456, 0.457, 0.458, 0.459, 0.46, 0.461, 0.462, 0.463, 0.464, 0.465, 0.466, 0.467, 0.468, 0.469, 0.47, 0.471, 0.472, 0.473, 0.474, 0.475, 0.476, 0.477, 0.478, 0.479, 0.48, 0.481, 0.482, 0.483, 0.484, 0.485, 0.486, 0.487, 0.488, 0.489, 0.49, 0.491, 0.492, 0.493, 0.494, 0.495, 0.496, 0.497, 0.498, 0.499, 0.5]), B=None)#

Calculate atomic form factors

fsc2res(fsc, cutoff=0.5, return_plot=False)#

Calculate resolution from the FSC curve using the cutoff given.

fsc - an Nx2 array, where the first column is the x axis given as

as 1/resolution (angstrom).

cutoff - the fsc value at which to estimate resolution, default=0.5. return_plot - return additional arrays for plotting (x, y, resx)

generate_enantiomers(rho)#

Generate all enantiomers of given density map. Output maps are original, and flipped over z.

grid_center(rho)#
inertia_tensor(rho, side)#

Calculate the moment of inertia tensor for the given electron density map.

largest_indices(a, n)#

Returns the n largest indices from a numpy array.

loadDatFile(filename)#

Loads a Primus .dat format file. Taken from the BioXTAS RAW software package, used with permission under the GPL license.

loadFitFile(filename)#

Loads a four column .fit format file (q, I, err, fit). Taken from the BioXTAS RAW software package, used with permission under the GPL license.

loadOldFitFile(filename)#

Loads a old denss _fit.dat format file. Taken from the BioXTAS RAW software package, used with permission under the GPL license.

loadOutFile(filename)#

Loads a GNOM .out file and returns q, Ireg, sqrt(Ireg), and a dictionary of miscellaneous results from GNOM. Taken from the BioXTAS RAW software package, used with permission under the GPL license.

loadProfile(fname, units='a')#

Determines which loading function to run, and then runs it.

minimize_rho(refrho, movrho, T=array([0., 0., 0., 0., 0., 0.]))#

Optimize superposition of electron density maps. Move movrho to refrho.

minimize_rho_score(T, refrho, movrho)#

Scoring function for superposition of electron density maps.

refrho - fixed, reference rho movrho - moving rho T - 6-element list containing alpha, beta, gamma, Tx, Ty, Tz in that order to move movrho by.

multi_average_two(niter, **kwargs)#

Wrapper script for averaging two maps for multiprocessing.

myabs(x, out=None, DENSS_GPU=False)#
mybinmean(xravel, binsravel, xcount=None, DENSS_GPU=False)#
mybinmean_optimized(xravel, binsravel, xcount=None, out=None)#
myfftn(x, DENSS_GPU=False)#
myifftn(x, DENSS_GPU=False)#
myirfftn(x, DENSS_GPU=False)#
mylog(x, DENSS_GPU=False)#
mymean(x, DENSS_GPU=False)#
myones(x, DENSS_GPU=False)#
myrfftn(x, DENSS_GPU=False)#
mysqrt(x, DENSS_GPU=False)#
mystd(x, DENSS_GPU=False)#
mysum(x, out=None, DENSS_GPU=False)#
myzeros(x, DENSS_GPU=False)#
myzeros_like(x, DENSS_GPU=False)#
pad_rho(rho, newshape)#

Pad rho with zeros to achieve new shape

pdb2F_multigauss(pdb, qx, qy, qz, qr=None, radii=None, B=None)#

Calculate structure factors F from pdb coordinates.

pdb - instance of PDB class (required) x,y,z - meshgrids for x, y, and z (required) radii - float or list of radii of atoms in pdb (optional, uses spherical form factor rather than Kromer-Mann)

pdb2F_simple_gauss_by_radius(pdb, qx, qy, qz, qr=None, rho0=0.334, radii=None, B=None)#

Calculate structure factors F from pdb coordinates.

pdb - instance of PDB class (required) x,y,z - meshgrids for x, y, and z (required) radii - float or list of radii of atoms in pdb (optional, uses spherical form factor rather than Kromer-Mann)

pdb2map_FFT(pdb, x, y, z, radii=None, restrict=True)#

Calculate electron density from pdb coordinates by FFT of Fs.

pdb - instance of PDB class (required) x,y,z - meshgrids for x, y, and z (required) radii - float or list of radii of atoms in pdb (optional, uses spherical form factor rather than Kromer-Mann)

pdb2map_multigauss(pdb, x, y, z, cutoff=3.0, global_B=None, use_b=False, ignore_waters=True)#

5-term gaussian sum at coordinate locations using Cromer-Mann coefficients.

This function only calculates the values at grid points near the atom for speed.

pdb - instance of PDB class (required) x,y,z - meshgrids for x, y, and z (required) cutoff - maximum distance from atom to calculate density global_B - desired resolution of density map, calculated as a B-factor corresonding to atomic displacement equal to resolution.

pdb2map_simple_gauss_by_radius(pdb, x, y, z, cutoff=3.0, global_B=None, rho0=0.334, ignore_waters=True)#

Simple isotropic single gaussian sum at coordinate locations.

This function only calculates the values at grid points near the atom for speed.

pdb - instance of PDB class (required, must have pdb.radius attribute) x,y,z - meshgrids for x, y, and z (required) cutoff - maximum distance from atom to calculate density rho0 - average bulk solvent density used for excluded volume estimation (0.334 for water)

pdb2support_SES(pdb, x, y, z, radius=None, probe=1.4)#

Return a 3D Boolean array of the Solvent Excluded Surface from a set of coordinates.

pdb - instance of PDB() class x,y,z - meshgrid arrays containing x, y, and z coordinates for all voxels of 3D support space probe - probe radius for ses determination (defaults to 1.4 for water)

pdb2support_fast(pdb, x, y, z, radius=None, probe=0.0)#

Return a boolean 3D density map with support from PDB coordinates

pdb2support_vdW(pdb, x, y, z, radius=None, probe=0.0)#

Return a boolean 3D density map with support from PDB coordinates

principal_axes(I)#

Calculate the principal inertia axes and order them Ia < Ib < Ic.

principal_axis_alignment(refrho, movrho)#

Align movrho principal axes to refrho.

read_mrc(filename='map.mrc', returnABC=False, float64=True)#

See MRC format at http://bio3d.colorado.edu/imod/doc/mrc_format.txt for offsets

real_space_correlation_coefficient(rho1, rho2, threshold=None)#

Real space correlation coefficient between two density maps.

threshold - fraction of max(rho1)

realspace_formfactor(element, r=array([0., 0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009, 0.01, 0.011, 0.012, 0.013, 0.014, 0.015, 0.016, 0.017, 0.018, 0.019, 0.02, 0.021, 0.022, 0.023, 0.024, 0.025, 0.026, 0.027, 0.028, 0.029, 0.03, 0.031, 0.032, 0.033, 0.034, 0.035, 0.036, 0.037, 0.038, 0.039, 0.04, 0.041, 0.042, 0.043, 0.044, 0.045, 0.046, 0.047, 0.048, 0.049, 0.05, 0.051, 0.052, 0.053, 0.054, 0.055, 0.056, 0.057, 0.058, 0.059, 0.06, 0.061, 0.062, 0.063, 0.064, 0.065, 0.066, 0.067, 0.068, 0.069, 0.07, 0.071, 0.072, 0.073, 0.074, 0.075, 0.076, 0.077, 0.078, 0.079, 0.08, 0.081, 0.082, 0.083, 0.084, 0.085, 0.086, 0.087, 0.088, 0.089, 0.09, 0.091, 0.092, 0.093, 0.094, 0.095, 0.096, 0.097, 0.098, 0.099, 0.1, 0.101, 0.102, 0.103, 0.104, 0.105, 0.106, 0.107, 0.108, 0.109, 0.11, 0.111, 0.112, 0.113, 0.114, 0.115, 0.116, 0.117, 0.118, 0.119, 0.12, 0.121, 0.122, 0.123, 0.124, 0.125, 0.126, 0.127, 0.128, 0.129, 0.13, 0.131, 0.132, 0.133, 0.134, 0.135, 0.136, 0.137, 0.138, 0.139, 0.14, 0.141, 0.142, 0.143, 0.144, 0.145, 0.146, 0.147, 0.148, 0.149, 0.15, 0.151, 0.152, 0.153, 0.154, 0.155, 0.156, 0.157, 0.158, 0.159, 0.16, 0.161, 0.162, 0.163, 0.164, 0.165, 0.166, 0.167, 0.168, 0.169, 0.17, 0.171, 0.172, 0.173, 0.174, 0.175, 0.176, 0.177, 0.178, 0.179, 0.18, 0.181, 0.182, 0.183, 0.184, 0.185, 0.186, 0.187, 0.188, 0.189, 0.19, 0.191, 0.192, 0.193, 0.194, 0.195, 0.196, 0.197, 0.198, 0.199, 0.2, 0.201, 0.202, 0.203, 0.204, 0.205, 0.206, 0.207, 0.208, 0.209, 0.21, 0.211, 0.212, 0.213, 0.214, 0.215, 0.216, 0.217, 0.218, 0.219, 0.22, 0.221, 0.222, 0.223, 0.224, 0.225, 0.226, 0.227, 0.228, 0.229, 0.23, 0.231, 0.232, 0.233, 0.234, 0.235, 0.236, 0.237, 0.238, 0.239, 0.24, 0.241, 0.242, 0.243, 0.244, 0.245, 0.246, 0.247, 0.248, 0.249, 0.25, 0.251, 0.252, 0.253, 0.254, 0.255, 0.256, 0.257, 0.258, 0.259, 0.26, 0.261, 0.262, 0.263, 0.264, 0.265, 0.266, 0.267, 0.268, 0.269, 0.27, 0.271, 0.272, 0.273, 0.274, 0.275, 0.276, 0.277, 0.278, 0.279, 0.28, 0.281, 0.282, 0.283, 0.284, 0.285, 0.286, 0.287, 0.288, 0.289, 0.29, 0.291, 0.292, 0.293, 0.294, 0.295, 0.296, 0.297, 0.298, 0.299, 0.3, 0.301, 0.302, 0.303, 0.304, 0.305, 0.306, 0.307, 0.308, 0.309, 0.31, 0.311, 0.312, 0.313, 0.314, 0.315, 0.316, 0.317, 0.318, 0.319, 0.32, 0.321, 0.322, 0.323, 0.324, 0.325, 0.326, 0.327, 0.328, 0.329, 0.33, 0.331, 0.332, 0.333, 0.334, 0.335, 0.336, 0.337, 0.338, 0.339, 0.34, 0.341, 0.342, 0.343, 0.344, 0.345, 0.346, 0.347, 0.348, 0.349, 0.35, 0.351, 0.352, 0.353, 0.354, 0.355, 0.356, 0.357, 0.358, 0.359, 0.36, 0.361, 0.362, 0.363, 0.364, 0.365, 0.366, 0.367, 0.368, 0.369, 0.37, 0.371, 0.372, 0.373, 0.374, 0.375, 0.376, 0.377, 0.378, 0.379, 0.38, 0.381, 0.382, 0.383, 0.384, 0.385, 0.386, 0.387, 0.388, 0.389, 0.39, 0.391, 0.392, 0.393, 0.394, 0.395, 0.396, 0.397, 0.398, 0.399, 0.4, 0.401, 0.402, 0.403, 0.404, 0.405, 0.406, 0.407, 0.408, 0.409, 0.41, 0.411, 0.412, 0.413, 0.414, 0.415, 0.416, 0.417, 0.418, 0.419, 0.42, 0.421, 0.422, 0.423, 0.424, 0.425, 0.426, 0.427, 0.428, 0.429, 0.43, 0.431, 0.432, 0.433, 0.434, 0.435, 0.436, 0.437, 0.438, 0.439, 0.44, 0.441, 0.442, 0.443, 0.444, 0.445, 0.446, 0.447, 0.448, 0.449, 0.45, 0.451, 0.452, 0.453, 0.454, 0.455, 0.456, 0.457, 0.458, 0.459, 0.46, 0.461, 0.462, 0.463, 0.464, 0.465, 0.466, 0.467, 0.468, 0.469, 0.47, 0.471, 0.472, 0.473, 0.474, 0.475, 0.476, 0.477, 0.478, 0.479, 0.48, 0.481, 0.482, 0.483, 0.484, 0.485, 0.486, 0.487, 0.488, 0.489, 0.49, 0.491, 0.492, 0.493, 0.494, 0.495, 0.496, 0.497, 0.498, 0.499, 0.5]), B=None)#

Calculate real space atomic form factors

realspace_gaussian_formfactor(r=array([-3., -2.94, -2.88, -2.82, -2.76, -2.7, -2.64, -2.58, -2.52, -2.46, -2.4, -2.34, -2.28, -2.22, -2.16, -2.1, -2.04, -1.98, -1.92, -1.86, -1.8, -1.74, -1.68, -1.62, -1.56, -1.5, -1.44, -1.38, -1.32, -1.26, -1.2, -1.14, -1.08, -1.02, -0.96, -0.9, -0.84, -0.78, -0.72, -0.66, -0.6, -0.54, -0.48, -0.42, -0.36, -0.3, -0.24, -0.18, -0.12, -0.06, 0., 0.06, 0.12, 0.18, 0.24, 0.3, 0.36, 0.42, 0.48, 0.54, 0.6, 0.66, 0.72, 0.78, 0.84, 0.9, 0.96, 1.02, 1.08, 1.14, 1.2, 1.26, 1.32, 1.38, 1.44, 1.5, 1.56, 1.62, 1.68, 1.74, 1.8, 1.86, 1.92, 1.98, 2.04, 2.1, 2.16, 2.22, 2.28, 2.34, 2.4, 2.46, 2.52, 2.58, 2.64, 2.7, 2.76, 2.82, 2.88, 2.94, 3.]), rho0=0.334, V=None, radius=None, B=None)#

Calculate real space atomic form factors assuming an isotropic gaussian sphere (for excluded volume).

reciprocalspace_gaussian_formfactor(q=array([0., 0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009, 0.01, 0.011, 0.012, 0.013, 0.014, 0.015, 0.016, 0.017, 0.018, 0.019, 0.02, 0.021, 0.022, 0.023, 0.024, 0.025, 0.026, 0.027, 0.028, 0.029, 0.03, 0.031, 0.032, 0.033, 0.034, 0.035, 0.036, 0.037, 0.038, 0.039, 0.04, 0.041, 0.042, 0.043, 0.044, 0.045, 0.046, 0.047, 0.048, 0.049, 0.05, 0.051, 0.052, 0.053, 0.054, 0.055, 0.056, 0.057, 0.058, 0.059, 0.06, 0.061, 0.062, 0.063, 0.064, 0.065, 0.066, 0.067, 0.068, 0.069, 0.07, 0.071, 0.072, 0.073, 0.074, 0.075, 0.076, 0.077, 0.078, 0.079, 0.08, 0.081, 0.082, 0.083, 0.084, 0.085, 0.086, 0.087, 0.088, 0.089, 0.09, 0.091, 0.092, 0.093, 0.094, 0.095, 0.096, 0.097, 0.098, 0.099, 0.1, 0.101, 0.102, 0.103, 0.104, 0.105, 0.106, 0.107, 0.108, 0.109, 0.11, 0.111, 0.112, 0.113, 0.114, 0.115, 0.116, 0.117, 0.118, 0.119, 0.12, 0.121, 0.122, 0.123, 0.124, 0.125, 0.126, 0.127, 0.128, 0.129, 0.13, 0.131, 0.132, 0.133, 0.134, 0.135, 0.136, 0.137, 0.138, 0.139, 0.14, 0.141, 0.142, 0.143, 0.144, 0.145, 0.146, 0.147, 0.148, 0.149, 0.15, 0.151, 0.152, 0.153, 0.154, 0.155, 0.156, 0.157, 0.158, 0.159, 0.16, 0.161, 0.162, 0.163, 0.164, 0.165, 0.166, 0.167, 0.168, 0.169, 0.17, 0.171, 0.172, 0.173, 0.174, 0.175, 0.176, 0.177, 0.178, 0.179, 0.18, 0.181, 0.182, 0.183, 0.184, 0.185, 0.186, 0.187, 0.188, 0.189, 0.19, 0.191, 0.192, 0.193, 0.194, 0.195, 0.196, 0.197, 0.198, 0.199, 0.2, 0.201, 0.202, 0.203, 0.204, 0.205, 0.206, 0.207, 0.208, 0.209, 0.21, 0.211, 0.212, 0.213, 0.214, 0.215, 0.216, 0.217, 0.218, 0.219, 0.22, 0.221, 0.222, 0.223, 0.224, 0.225, 0.226, 0.227, 0.228, 0.229, 0.23, 0.231, 0.232, 0.233, 0.234, 0.235, 0.236, 0.237, 0.238, 0.239, 0.24, 0.241, 0.242, 0.243, 0.244, 0.245, 0.246, 0.247, 0.248, 0.249, 0.25, 0.251, 0.252, 0.253, 0.254, 0.255, 0.256, 0.257, 0.258, 0.259, 0.26, 0.261, 0.262, 0.263, 0.264, 0.265, 0.266, 0.267, 0.268, 0.269, 0.27, 0.271, 0.272, 0.273, 0.274, 0.275, 0.276, 0.277, 0.278, 0.279, 0.28, 0.281, 0.282, 0.283, 0.284, 0.285, 0.286, 0.287, 0.288, 0.289, 0.29, 0.291, 0.292, 0.293, 0.294, 0.295, 0.296, 0.297, 0.298, 0.299, 0.3, 0.301, 0.302, 0.303, 0.304, 0.305, 0.306, 0.307, 0.308, 0.309, 0.31, 0.311, 0.312, 0.313, 0.314, 0.315, 0.316, 0.317, 0.318, 0.319, 0.32, 0.321, 0.322, 0.323, 0.324, 0.325, 0.326, 0.327, 0.328, 0.329, 0.33, 0.331, 0.332, 0.333, 0.334, 0.335, 0.336, 0.337, 0.338, 0.339, 0.34, 0.341, 0.342, 0.343, 0.344, 0.345, 0.346, 0.347, 0.348, 0.349, 0.35, 0.351, 0.352, 0.353, 0.354, 0.355, 0.356, 0.357, 0.358, 0.359, 0.36, 0.361, 0.362, 0.363, 0.364, 0.365, 0.366, 0.367, 0.368, 0.369, 0.37, 0.371, 0.372, 0.373, 0.374, 0.375, 0.376, 0.377, 0.378, 0.379, 0.38, 0.381, 0.382, 0.383, 0.384, 0.385, 0.386, 0.387, 0.388, 0.389, 0.39, 0.391, 0.392, 0.393, 0.394, 0.395, 0.396, 0.397, 0.398, 0.399, 0.4, 0.401, 0.402, 0.403, 0.404, 0.405, 0.406, 0.407, 0.408, 0.409, 0.41, 0.411, 0.412, 0.413, 0.414, 0.415, 0.416, 0.417, 0.418, 0.419, 0.42, 0.421, 0.422, 0.423, 0.424, 0.425, 0.426, 0.427, 0.428, 0.429, 0.43, 0.431, 0.432, 0.433, 0.434, 0.435, 0.436, 0.437, 0.438, 0.439, 0.44, 0.441, 0.442, 0.443, 0.444, 0.445, 0.446, 0.447, 0.448, 0.449, 0.45, 0.451, 0.452, 0.453, 0.454, 0.455, 0.456, 0.457, 0.458, 0.459, 0.46, 0.461, 0.462, 0.463, 0.464, 0.465, 0.466, 0.467, 0.468, 0.469, 0.47, 0.471, 0.472, 0.473, 0.474, 0.475, 0.476, 0.477, 0.478, 0.479, 0.48, 0.481, 0.482, 0.483, 0.484, 0.485, 0.486, 0.487, 0.488, 0.489, 0.49, 0.491, 0.492, 0.493, 0.494, 0.495, 0.496, 0.497, 0.498, 0.499, 0.5]), rho0=0.334, V=None, radius=None, B=None)#

Calculate reciprocal space atomic form factors assuming an isotropic gaussian sphere (for excluded volume).

reconstruct_abinitio_from_scattering_profile(q, I, sigq, dmax, qraw=None, Iraw=None, sigqraw=None, ne=None, voxel=5.0, oversampling=3.0, recenter=True, recenter_steps=None, recenter_mode='com', positivity=True, positivity_steps=None, extrapolate=True, output='map', steps=None, seed=None, rho_start=None, support_start=None, add_noise=None, shrinkwrap=True, shrinkwrap_old_method=False, shrinkwrap_sigma_start=3, shrinkwrap_sigma_end=1.5, shrinkwrap_sigma_decay=0.99, shrinkwrap_threshold_fraction=0.2, shrinkwrap_iter=20, shrinkwrap_minstep=100, chi_end_fraction=0.01, write_xplor_format=False, write_freq=100, enforce_connectivity=True, enforce_connectivity_steps=[500], enforce_connectivity_max_features=1, cutout=True, quiet=False, ncs=0, ncs_steps=[500], ncs_axis=1, ncs_type='cyclical', abort_event=None, my_logger=<RootLogger root (WARNING)>, path='.', gui=False, DENSS_GPU=False, progress_cb=None)#

Calculate electron density from scattering data.

regrid_Iq(Iq, qmin=None, qmax=None, nq=None, qc=None, use_sasrec=False, D=None)#

Interpolate Iq_calc to desired qgrid. qmax - maximum desired q value (e.g. 0.5, optional) nq - number of q points desired (equispaced from qmin to qmax, e.g., 501, optional) qc - desired q grid (takes precedence over qmax/nq) use_sasrec - rather than using simple scipy interpolation, use the more accurate (but slower) sasrec for interpolation D - maximum dimension of particle (useful for sasrec, if not given, estimated automatically from the data)

rho2rg(rho, side=None, r=None, support=None, dx=None)#

Calculate radius of gyration from an electron density map.

rho_overlap_score(rho1, rho2, threshold=None)#

Scoring function for superposition of electron density maps.

rotate_coordinates(coordinates, degrees_x=0, degrees_y=0, degrees_z=0)#
running_mean(x, N)#
select_best_enantiomer(refrho, rho, abort_event=None)#

Generate, align and select the enantiomer that best fits the reference map.

select_best_enantiomers(rhos, refrho=None, cores=1, avg_queue=None, abort_event=None, single_proc=False)#

Select the best enantiomer from each map in the set (or a single map). refrho should not be binary averaged from the original denss maps, since that would likely lose handedness. By default, refrho will be set to the first map.

shrinkwrap_by_density_value(rho, absv=True, sigma=3.0, threshold=0.2, recenter=True, recenter_mode='com')#

Create support using shrinkwrap method based on threshold as fraction of maximum density

rho - electron density; numpy array absv - boolean, whether or not to take the absolute value of the density sigma - sigma, in pixels, for gaussian filter threshold - fraction of maximum gaussian filtered density (0 to 1) recenter - boolean, whether or not to recenter the density prior to calculating support recenter_mode - either com (center of mass) or max (maximum density value)

shrinkwrap_by_volume(rho, N, absv=True, sigma=3.0, recenter=True, recenter_mode='com')#

Create support using shrinkwrap method based on threshold as fraction of maximum density

rho - electron density; numpy array absv - boolean, whether or not to take the absolute value of the density sigma - sigma, in pixels, for gaussian filter N - set the threshold such that N voxels are in the support (must precalculate this based on volume) recenter - boolean, whether or not to recenter the density prior to calculating support recenter_mode - either com (center of mass) or max (maximum density value)

sigmoid(x, x0, k, b, L)#
sigmoid_find_x_value_given_y(y, x0, k, b, L)#

find the corresponding x value given a desired y value on a sigmoid curve

sphere(R, q=array([0., 0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009, 0.01, 0.011, 0.012, 0.013, 0.014, 0.015, 0.016, 0.017, 0.018, 0.019, 0.02, 0.021, 0.022, 0.023, 0.024, 0.025, 0.026, 0.027, 0.028, 0.029, 0.03, 0.031, 0.032, 0.033, 0.034, 0.035, 0.036, 0.037, 0.038, 0.039, 0.04, 0.041, 0.042, 0.043, 0.044, 0.045, 0.046, 0.047, 0.048, 0.049, 0.05, 0.051, 0.052, 0.053, 0.054, 0.055, 0.056, 0.057, 0.058, 0.059, 0.06, 0.061, 0.062, 0.063, 0.064, 0.065, 0.066, 0.067, 0.068, 0.069, 0.07, 0.071, 0.072, 0.073, 0.074, 0.075, 0.076, 0.077, 0.078, 0.079, 0.08, 0.081, 0.082, 0.083, 0.084, 0.085, 0.086, 0.087, 0.088, 0.089, 0.09, 0.091, 0.092, 0.093, 0.094, 0.095, 0.096, 0.097, 0.098, 0.099, 0.1, 0.101, 0.102, 0.103, 0.104, 0.105, 0.106, 0.107, 0.108, 0.109, 0.11, 0.111, 0.112, 0.113, 0.114, 0.115, 0.116, 0.117, 0.118, 0.119, 0.12, 0.121, 0.122, 0.123, 0.124, 0.125, 0.126, 0.127, 0.128, 0.129, 0.13, 0.131, 0.132, 0.133, 0.134, 0.135, 0.136, 0.137, 0.138, 0.139, 0.14, 0.141, 0.142, 0.143, 0.144, 0.145, 0.146, 0.147, 0.148, 0.149, 0.15, 0.151, 0.152, 0.153, 0.154, 0.155, 0.156, 0.157, 0.158, 0.159, 0.16, 0.161, 0.162, 0.163, 0.164, 0.165, 0.166, 0.167, 0.168, 0.169, 0.17, 0.171, 0.172, 0.173, 0.174, 0.175, 0.176, 0.177, 0.178, 0.179, 0.18, 0.181, 0.182, 0.183, 0.184, 0.185, 0.186, 0.187, 0.188, 0.189, 0.19, 0.191, 0.192, 0.193, 0.194, 0.195, 0.196, 0.197, 0.198, 0.199, 0.2, 0.201, 0.202, 0.203, 0.204, 0.205, 0.206, 0.207, 0.208, 0.209, 0.21, 0.211, 0.212, 0.213, 0.214, 0.215, 0.216, 0.217, 0.218, 0.219, 0.22, 0.221, 0.222, 0.223, 0.224, 0.225, 0.226, 0.227, 0.228, 0.229, 0.23, 0.231, 0.232, 0.233, 0.234, 0.235, 0.236, 0.237, 0.238, 0.239, 0.24, 0.241, 0.242, 0.243, 0.244, 0.245, 0.246, 0.247, 0.248, 0.249, 0.25, 0.251, 0.252, 0.253, 0.254, 0.255, 0.256, 0.257, 0.258, 0.259, 0.26, 0.261, 0.262, 0.263, 0.264, 0.265, 0.266, 0.267, 0.268, 0.269, 0.27, 0.271, 0.272, 0.273, 0.274, 0.275, 0.276, 0.277, 0.278, 0.279, 0.28, 0.281, 0.282, 0.283, 0.284, 0.285, 0.286, 0.287, 0.288, 0.289, 0.29, 0.291, 0.292, 0.293, 0.294, 0.295, 0.296, 0.297, 0.298, 0.299, 0.3, 0.301, 0.302, 0.303, 0.304, 0.305, 0.306, 0.307, 0.308, 0.309, 0.31, 0.311, 0.312, 0.313, 0.314, 0.315, 0.316, 0.317, 0.318, 0.319, 0.32, 0.321, 0.322, 0.323, 0.324, 0.325, 0.326, 0.327, 0.328, 0.329, 0.33, 0.331, 0.332, 0.333, 0.334, 0.335, 0.336, 0.337, 0.338, 0.339, 0.34, 0.341, 0.342, 0.343, 0.344, 0.345, 0.346, 0.347, 0.348, 0.349, 0.35, 0.351, 0.352, 0.353, 0.354, 0.355, 0.356, 0.357, 0.358, 0.359, 0.36, 0.361, 0.362, 0.363, 0.364, 0.365, 0.366, 0.367, 0.368, 0.369, 0.37, 0.371, 0.372, 0.373, 0.374, 0.375, 0.376, 0.377, 0.378, 0.379, 0.38, 0.381, 0.382, 0.383, 0.384, 0.385, 0.386, 0.387, 0.388, 0.389, 0.39, 0.391, 0.392, 0.393, 0.394, 0.395, 0.396, 0.397, 0.398, 0.399, 0.4, 0.401, 0.402, 0.403, 0.404, 0.405, 0.406, 0.407, 0.408, 0.409, 0.41, 0.411, 0.412, 0.413, 0.414, 0.415, 0.416, 0.417, 0.418, 0.419, 0.42, 0.421, 0.422, 0.423, 0.424, 0.425, 0.426, 0.427, 0.428, 0.429, 0.43, 0.431, 0.432, 0.433, 0.434, 0.435, 0.436, 0.437, 0.438, 0.439, 0.44, 0.441, 0.442, 0.443, 0.444, 0.445, 0.446, 0.447, 0.448, 0.449, 0.45, 0.451, 0.452, 0.453, 0.454, 0.455, 0.456, 0.457, 0.458, 0.459, 0.46, 0.461, 0.462, 0.463, 0.464, 0.465, 0.466, 0.467, 0.468, 0.469, 0.47, 0.471, 0.472, 0.473, 0.474, 0.475, 0.476, 0.477, 0.478, 0.479, 0.48, 0.481, 0.482, 0.483, 0.484, 0.485, 0.486, 0.487, 0.488, 0.489, 0.49, 0.491, 0.492, 0.493, 0.494, 0.495, 0.496, 0.497, 0.498, 0.499, 0.5]), I0=1.0, amp=False)#

Calculate the scattering of a uniform sphere.

sphere_radius_from_volume(V)#
sphere_volume_from_radius(R)#
spherical_cap_volume(R, h)#
spherical_to_euler(phi, theta)#

Convert spherical coordinates (phi, theta) to Euler angles (alpha, beta, gamma).

transform_rho(rho, T, order=1)#

Rotate and translate electron density map by T vector. T = [alpha, beta, gamma, x, y, z], angles in radians order = interpolation order (0-5)

u2B(u)#

Calculate B-factor from atomic displacement, u

v2B(v)#

Calculate B-factor from atomic volume displacement, v

write_mrc(rho, side, filename='map.mrc')#

Write an MRC formatted electron density map. See here: http://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/image-processing-software/#image

write_xplor(rho, side, filename='map.xplor')#

Write an XPLOR formatted electron density map.

zoom_rho(rho, vx, dx)#

Resample rho to have new voxel size.

rho - map to resample (3D array) vx - length of voxel of rho, float or tuple of three sides (a,b,c) dx - desired voxel size (only float allowed, assumes cubic grid desired)