Numba Utils
- compute_bin(x: float, bin_edges: ndarray) int
Compute determine bin for a given observation, x
- Parameters:
x (float) – Observation.
bin_edges (np.ndarray) – Available bins.
- Returns:
bin – Index of bin to add observation to.
- Return type:
int
- dirichlet(x: ndarray) ndarray
Dirichlet distribution sampler
- Parameters:
x (np.ndarray) – Parameters of dirichlet distribution to sample from.
- Returns:
dist – Random sample from dirichlet distribution with parameters x.
- Return type:
np.ndarray
- get_delta_r(r: ndarray) float
Calculates increment of a sorted array with evenly distributed floats
- Parameters:
r (np.ndarray) – Array of equally spaced consecutive numbers.
- Returns:
delta_r – Distance between numbers in r.
- Return type:
float
- histogram(a: ndarray, weights: ndarray, r: ndarray) ndarray
Calculate histogram for observations,
a
, with weights over the domain, r, as precursor for KDE of distance distribution.- Parameters:
a (np.ndarray) – Array of relevant pairwise distances between NO midpoint libraries.
weights (np.ndarray) – Weights array corresponding to distances in
a
.r (np.ndarray) – Domain of distance distribution.
- Returns:
hist – Weighted histogram of pairwise distances.
- Return type:
np.ndarray
- jaccard(p: ndarray, q: ndarray) float
Calculate the jaccard index between the two provided vectors (distance distributions)
- Parameters:
p (np.ndarray) – Sets to calculate the jaccard index between.
q (np.ndarray) – Sets to calculate the jaccard index between.
- Returns:
jac – Jaccard index between
q
andp
.- Return type:
float
- kl_divergence(p: ndarray, q: ndarray) float
Compute the Kullback–Leibler divergence (KLD) of
p
andq
.- Parameters:
p (np.ndarray) – The distributions to calculate the KLD between.
q (np.ndarray) – The distributions to calculate the KLD between.
- Returns:
kld – The Kullback–Leibler divergence between
p
andq
.- Return type:
float
- normdist(delta_r: float, mu: float = 0.0, sigma: float = 1.0) Tuple[ndarray, ndarray]
Calculate normal distribution for convolution with histogram of distances between two spin label ensembles
- Parameters:
delta_r (float) – Space between points in distance domain.
mu (float) – Mean for normal distribution.
sigma (float) – Standard deviation of normal distribution.
- Returns:
x (np.ndarray) – Domain of the distribution.
y (np.ndarray) – PDF values of the distribution.
- pairwise_dist(x: ndarray, y: ndarray) ndarray
Calculate the pairwise (euclidean) distance between the coordinate sets.
- Parameters:
x (np.ndarray) – Coordinate sets to calcualte the distance between
y (np.ndarray) – Coordinate sets to calcualte the distance between
- Returns:
distances – Pairwise distance matrix between coordinates of x and y.
- Return type:
np.ndarray
- np_all_axis1(x: ndarray) ndarray
Numba compatible version of np.all(x, axis=1).
- Parameters:
x ((M, N) np.ndarray) – Boolean input array.
- Returns:
out – Boolean array indicating if all values in the second axis of
x
are true.- Return type:
(M,) np.ndarray
- get_sasa(atom_coords: ndarray, atom_radii: ndarray, environment_coords: ndarray | None = None, environment_radii: ndarray | None = None, probe_radius: float = 1.4, npoints: int = 1024, by_atom: bool = False) ndarray
- Parameters:
atom_coords ((M, N, 3) np.ndarray) – M frames of the 3D cartesian coordinates of the N atoms to calculate the SASA of.
atom_radii ((N,) np.ndarray) – vdW radii + solvent radii of the atoms in
atom_coords
environment_coords ((L, 3) np.ndarray) – 3D cartesian coordinates of the atoms nearby the atoms for which the SASA is desired.
environment_radii ((L,) np.ndarray) – vdW radii + solvent radii of the atoms in
env_coords
probe_radius (flaot) – Radius of the solvent probe.
npoints (int) – Number of points to use in sphere used for SASA calculation
by_atom (bool) – Return SASA of each atom rather than the set of atoms
- Returns:
sasa – Solvent accessible surface areas of the provided coords in the provided environment.
- Return type:
np.ndarray:
- fibonacci_points(n: int) ndarray
Get
n
evenly spaced points on the unit sphere using the fibonacci method.- Parameters:
n (int) – Number of points to return.
- Returns:
coords – 3D coordinates of the points on the unit sphere.
- Return type:
np.ndarray