spyrmsd.hungarian module

spyrmsd.hungarian.cost_mtx(A: ndarray, B: ndarray)[source]

Compute the cost matrix for atom-atom assignment.

Parameters
  • A (numpy.ndarray) – Atomic coordinates of molecule A

  • B (numpy.ndarray) – Atomic coordinates of molecule B

Returns

Cost matrix of squared atomic distances between atoms of molecules A and B

Return type

np.ndarray

spyrmsd.hungarian.hungarian_rmsd(A: ndarray, B: ndarray, apropsA: ndarray, apropsB: ndarray) float[source]

Solve the optimal assignment problems between atomic coordinates of molecules A and B.

Parameters
  • A (numpy.ndarray) – Atomic coordinates of molecule A

  • B (numpy.ndarray) – Atomic coordinates of molecule B

  • apropsA (numpy.ndarray) – Atomic properties of molecule A

  • apropsB (numpy.ndarray) – Atomic properties of molecule B

Returns

RMSD computed with the Hungarian method

Return type

float

Notes

The Hungarian algorithm is used to solve the linear assignment problem, which is a minimum weight matching of the molecular graphs (bipartite).

The linear assignment problem is solved for every element separately. 1

1

W. J. Allen and R. C. Rizzo, Implementation of the Hungarian Algorithm to Account for Ligand Symmetry and Similarity in Structure-Based Design, J. Chem. Inf. Model. 54, 518-529 (2014)

spyrmsd.hungarian.optimal_assignment(A: ndarray, B: ndarray)[source]

Solve the optimal assignment problems between atomic coordinates of molecules A and B.

Parameters
  • A (numpy.ndarray) – Atomic coordinates of molecule A

  • B (numpy.ndarray) – Atomic coordinates of molecule B

Returns

Cost of the optimal assignment, together with the row and column indices of said assignment

Return type

Tuple[float, nd.array, nd.array]