distances : Utility functions to calculate structural similarity

idpflex.distances.distance_submatrix(dist_mat, indexes)[source]

Extract matrix of distances for a subset of indexes

If matrix is in condensed format, then the submatrix is returned in condensed format too.

Parameters
  • dist_mat (ndarray) – NxN distance matrix

  • indexes (sequence of int) – sequence of indexes from which a submatrix is extracted.

Returns

Return type

ndarray

idpflex.distances.extract_coordinates(a_universe, group, indexes=None)[source]

Obtain XYZ coordinates for an atom group and for a subset of frames

Parameters
  • a_universe (Universe) – Topology and trajectory.

  • group (AtomGroup) – Atom selection.

  • indexes (list) – sequence of frame indexes

Returns

XYZ coordinates shape=(M, N, 3) with M number of indexes and N number of atoms in group.

Return type

ndarray

idpflex.distances.generate_distance_matrix(feature_vectors, weights=None, func1d=<function zscore>, func1d_args=None, func1d_kwargs=None)[source]

Calculate a distance matrix between measurements, based on features of the measurements

Each measurement is characterized by a set of features, here implemented as a vector. Thus, we sample each feature vector-item a number of times equal to the number of measurements.

Distance d between two feature vectors f and g given weights w

`d**2 = sum_i w_i * (f_i - g_i)**2

Parameters
  • feature_vectors (list) – List of feature vectors, one vector for each measurement

  • weights (list) – List of feature weight vectors, one for each measurement

  • func1d (function) – Apply this function to the set of values obtained for each feature vector-item. The size of the set is number of measurements. The default function transforms the values in each feature vector-item set such that the set has zero mean and unit standard deviation.

  • func1d_args (list) – Positional arguments to func1D

  • func1d_kwargs (dict) – Optional arguments for func1D

Returns

Distance matrix in vector-form distance

Return type

numpy.ndarray

idpflex.distances.rmsd_matrix(xyz, condensed=False)[source]

RMSD matrix between coordinate frames.

Parameters
  • xyz (ndarray) – Bare coordinates shape=(N, M, 3) with N: number of frames, M: number of atoms

  • condensed (bool) – Flag return matrix as square or condensed

Returns

Square NxN matrix, or condensed N*(N+1)/2 matrix

Return type

ndarray