13.2.9. Fast QCP RMSD structure alignment — MDAnalysis.lib.qcprot

Author:Joshua L. Adelman, University of Pittsburgh
Author:Robert R. Delgado, Cornell University and Arizona State University
Year:2011, 2016

PyQCPROT is a python/cython implementation of Douglas Theobald’s QCP method for calculating the minimum RMSD between two structures [Theobald2005] and determining the optimal least-squares rotation matrix [Liu2010].

A full description of the method, along with the original C implementation can be found at http://theobald.brandeis.edu/qcp/

See also

Align structures using CalcRMSDRotationalMatrix()
Calculate the RMSD between two structures using CalcRMSDRotationalMatrix()

Changed in version 0.16.0: Call signatures were changed to directly interface with MDAnalysis coordinate arrays: shape (N, 3)


If you use this QCP rotation calculation method in a publication, please reference:

[Theobald2005]Douglas L. Theobald (2005) “Rapid calculation of RMSD using a quaternion-based characteristic polynomial.” Acta Crystallographica A 61(4):478-480.
[Liu2010]Pu Liu, Dmitris K. Agrafiotis, and Douglas L. Theobald (2010) “Fast determination of the optimal rotational matrix for macromolecular superpositions.” J. Comput. Chem. 31, 1561-1563. Functions

Users will typically use the CalcRMSDRotationalMatrix() function.


Calculate the RMSD & rotational matrix.

  • ref (ndarray, np.float64_t) – reference structure coordinates
  • conf (ndarray, np.float64_t) – condidate structure coordinates
  • N (int) – size of the system
  • rot (ndarray, np.float64_t) – array to store rotation matrix. Must be flat
  • weights (ndarray, npfloat64_t (optional)) – weights for each component

  • rmsd (float) – RMSD value
  • .. versionchanged:: 0.16.0 – Array size changed from 3xN to Nx3.


Calculate the inner product of two structures.

  • A (ndarray np.float64_t) – result inner product array, modified in place
  • coords1 (ndarray np.float64_t) – reference structure
  • coord2 (ndarray np.float64_t) – candidate structure
  • N (int) – size of system
  • weights (ndarray np.float64_t (optional)) – use to calculate weighted inner product


  1. You MUST center the structures, coords1 and coords2, before calling this function.
  2. Coordinates are stored as Nx3 arrays (as everywhere else in MDAnalysis).

Changed in version 0.16.0: Array size changed from 3xN to Nx3.


Calculate the RMSD, and/or the optimal rotation matrix.

  • rot (ndarray np.float64_t) – result rotation matrix, modified inplace
  • A (ndarray np.float64_t) – the inner product of two structures
  • E0 (float64) – 0.5 * (G1 + G2)
  • N (int) – size of the system

rmsd – RMSD value for two structures

Return type:


Changed in version 0.16.0: Array sized changed from 3xN to Nx3.