Module: rmsd

With this module you can calculate the Root Mean Squared Displacement (RMSD) for given configurations. The method is based on quaternionen as presented in Coutsias, E. A., Seok, C. & Dill, K. A. Using quaternions to calculate RMSD. Journal of Computational Chemistry 25, 1849–1857 (2004). It is important that the two configurations are of the same size.

Examples

Simple example
1import BioHelpers_FABER.rmsd as rmsd
2
3pdb1 = "file1.pdb"
4pdb2 = "file2.pdb"
5
6print(rmsd.rsmd_pdb(pdb1, pdb2))

Members

BioHelpers_FABER.rmsd.calc_bary(x: ndarray) ndarray

Calculation of the barycenter

BioHelpers_FABER.rmsd.get_rotation_matrix(x: ndarray, y: ndarray) ndarray

Get the rotation matrix to a corresponding set of atom vectors

Parameters:
  • x (np.ndarray) – set 1

  • y (np.ndarray) – set 2

Returns:

rotation matrix U(q_max)

Return type:

np.ndarray

BioHelpers_FABER.rmsd.get_translation_vector(x: ndarray, y: ndarray) ndarray

Get the translation vector \(\mathbf{r}\)
Important Note: The translation vector differs from Kabsch algorithm, there you translate befor rotating. In Coutsias paper it is the otherway round.

Parameters:
  • x (np.ndarray) – set of vectors

  • y (np.ndarray) – set of vectors

Returns:

translation vector w/ shape (3,1)

Return type:

np.ndarray

BioHelpers_FABER.rmsd.mat_R(x: ndarray, y: ndarray) ndarray

Calculation of R matrix

BioHelpers_FABER.rmsd.mat_U(q: ndarray) ndarray

Calculation of the rotation matrix U from quaternion q

Parameters:

q (np.ndarray) – Quaterion

Returns:

3x3 rotation matrix

Return type:

np.ndarray

BioHelpers_FABER.rmsd.rmsd(x: ndarray, y: ndarray) float

Calculation of Root Mean Square Displacement

Parameters:
  • x (np.ndarray) – Array of all atoms, molecule 1

  • y (np.ndarray) – Array of all atoms, molecule 2

Returns:

RMSD

Return type:

float

BioHelpers_FABER.rmsd.rmsd_from_rot_tran(x: ndarray, y: ndarray, rot: ndarray, trans: ndarray) float

Calculate an RMSD like value for a given set of vectors x and y with a given rotation matrix and translation vector Mathematical formula:

\[\mathrm{E} = \frac{1}{M} \sum_{k=1..M} |\mathscr{U}\mathbf{x}^k + \mathbf{r} - \mathbf{y}^k|^2\]

Important Note: The translation vector differs from Kabsch algorithm, there you translate before rotating. In Coutsias paper it is the otherway round.

Parameters:
  • x (np.ndarray) – Set of vectors

  • y (np.ndarray) – Set of vectors

  • rot (np.ndarray) – rotation matrix (3x3)

  • trans (np.ndarray) – Translation vector r, see note above

Returns:

RMSD like value (\(\sqrt{E}\))

Return type:

float

BioHelpers_FABER.rmsd.rmsd_pdb(file1: str, file2: str, exclude_residues: list | None = None) float

Calculate RMSD for two given PDBs

Parameters:
  • file1 (str) – Filename/Path of PDB/CIF1

  • file2 (str) – Filename/Path of PDB/CIF2

  • exclude_residues (list) – Which residues shouldn’t be considered for RMSD (eg. [(1,3), (9,12)] for not considering residue 1,2,3 and residue 9,10,11,12)

Returns:

RMSD as float, if files do not exist return 0

Return type:

float

BioHelpers_FABER.rmsd.rmsd_per_residue(file1: str, file2: str) list[float]

RMSD for all residues seperately

Parameters:
  • file1 (str) – PDB/cif File 1

  • file2 (str) – PDB/cif File 2

Returns:

List of length L (number of residues) with all rmsds per residue

Return type:

list[float]