Numba Utils
- compute_bin(x: float, bin_edges: ndarray) int[source]
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[source]
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[source]
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[source]
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[source]
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
qandp.- Return type:
float
- kl_divergence(p: ndarray, q: ndarray) float[source]
Compute the Kullback–Leibler divergence (KLD) of
pandq.- 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
pandq.- Return type:
float
- normdist(delta_r: float, mu: float = 0.0, sigma: float = 1.0) Tuple[ndarray, ndarray][source]
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[source]
Calculate the pairwise (Euclidean) distance between the coordinate sets.
- Parameters:
x (np.ndarray) – Coordinate sets to calculate the distance between
y (np.ndarray) – Coordinate sets to calculate the distance between
- Returns:
distances – Pairwise distance matrix between coordinates of x and y.
- Return type:
np.ndarray
- batch_ic2cart(IC_idx_Array: ndarray, ICArray: ndarray)[source]
Vectorization of ic2cart along the ICArray argument to calculate cartesian coordinates for multiple conformations.
- Parameters:
IC_idx_Array (np.ndarray) –
Array of indexes corresponding to the atoms defining the internal coordinate.
IC_idx_Array[i, 0] # index of the atom that atom
iis bonded to. IC_idx_Array[i, 1] # index of the atom that atomicreates an angle with. IC_idx_Array[i, 2] # index of the atom that atomicreates a dihedral angle with.A value of -1 indicates that there is no precursor atom to define the bond, angle or dihedral and that atom
iis one of the coordinate system defining atoms.ICArray –
Internal coordinate values for
nconformersIC_idx_Array[n, i, 0] # bond distance of the atom that atom
iand one of its precursor atoms. IC_idx_Array[n, i, 1] # bond angle between atomitwo of its precursor atoms. IC_idx_Array[n, i, 2] # index of the atom that atomicreates a dihedral angle with three of it’s precursor atoms.
- Returns:
coords – Array of cartesian coordinates corresponding to ICAtom list atoms
- Return type:
np.ndarray
- np_all_axis1(x: ndarray) ndarray[source]
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
xare 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[source]
- 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_coordsenvironment_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_coordsprobe_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: