Skip to main content

Calculate root-mean-square deviation (RMSD), using Kabsch or Quaternion algorithm for rotation, between two Cartesian coordinates in .xyz or .pdb format, resulting in the minimal RMSD.

Project description

https://travis-ci.org/charnley/rmsd.svg?branch=master https://badge.fury.io/py/rmsd.svg

Calculate Root-mean-square deviation (RMSD) of Two Molecules Using Rotation

The root-mean-square deviation (RMSD) is calculated, using Kabsch algorithm (1976) or Quaternion algorithm (1991) for rotation, between two Cartesian coordinates in either .xyz or .pdb format, resulting in the minimal RMSD.

For more information please read RMSD and Kabsch algorithm.

Motivation

You have molecule A and B and want to calculate the structural difference between those two. If you just calculate the RMSD straight-forward you might get a too big of a value as seen below. You would need to first recenter the two molecules and then rotate them unto each other to get the true minimal RMSD. This is what this script does.

No Changes

Re-centered

Rotated

begin

translate

rotate

RMSD 2.50

RMSD 1.07

RMSD 0.25

Installation

You can get the package via pip under the name rmsd,

pip install rmsd

or download the project from GitHub via

git clone https://github.com/charnley/rmsd

There is only one Python file, so you can also download that and put it in your bin folder.

wget -O calculate_rmsd https://raw.githubusercontent.com/charnley/rmsd/master/rmsd/calculate_rmsd.py
chmod +x calculate_rmsd

Usage

Type calculate_rmsd --help for all the arguments. Usage is pretty straight forward, call calculate_rmsd with two structures in either .xyz or .pdb. In this example Ethane has the exact same structure, but is translated in space, so the RMSD should be zero.

calculate_rmsd examples/ethane.xyz examples/ethane_translate.xyz

It is also possible to ignore all Hydrogens (useful for larger molecules where Hydrogens move around indistinguishable) and output the rotated structure for visual comparison. The output will be in XYZ format.

calculate_rmsd --no-hydrogen --output examples/ethane.xyz examples/ethane_mini.xyz

It is also possible to use RMSD as a library in other scripts:

import rmsd
import numpy as np
P = np.array([[-0.9835 ,  1.8109 , -0.0314 ],
       [ 0.1268 ,  1.8041 , -0.03242],
       [-1.4899 ,  3.2274 ,  0.18102],
       [-1.3504 ,  1.1535 ,  0.78475]])

Q = np.array([[-2.1217 ,  4.0933 ,  0.12713],
       [-1.0113 ,  4.0865 ,  0.12611],
       [-2.628  ,  5.5097 ,  0.33955],
       [-2.4885 ,  3.4358 ,  0.94328]])
print "RMSD before translation: ", rmsd.kabsch_rmsd(P, Q)
P -= rmsd.centroid(P)
Q -= rmsd.centroid(Q)
print "RMSD after translation: ", rmsd.kabsch_rmsd(P, Q)

Citation

  • Kabsch algorithm:

    Kabsch W., 1976, A solution for the best rotation to relate two sets of vectors, Acta Crystallographica, A32:922-923, doi: http://dx.doi.org/10.1107/S0567739476001873

  • Quaternion algorithm:

    Michael W. Walker and Lejun Shao and Richard A. Volz, 1991, Estimating 3-D location parameters using dual number quaternions, CVGIP: Image Understanding, 54:358-367, doi: http://dx.doi.org/10.1016/1049-9660(91)90036-o

  • Implementation:

    Calculate Root-mean-square deviation (RMSD) of Two Molecules Using Rotation, GitHub, http://github.com/charnley/rmsd, <commit hash or version number>

Please cite this project when using it for scientific publications.

Problems?

Submit issues or pull requests on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rmsd-1.2.6.tar.gz (7.9 kB view details)

Uploaded Source

File details

Details for the file rmsd-1.2.6.tar.gz.

File metadata

  • Download URL: rmsd-1.2.6.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for rmsd-1.2.6.tar.gz
Algorithm Hash digest
SHA256 b4e7cdbecbf16153c10b6db33abb1300430d4efede6ff6e980c9b3347ac51b85
MD5 49932a7276422361978eb435f49e6441
BLAKE2b-256 35d0849b181a50c810ba2b0b68804526934762f8df0735082f010d00f5327997

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page