Skip to main content

Calculate root-mean-square deviation (RMSD) between two sets of cartesian coordinates (XYZ or PDB format), using rotation (fx. Kabsch algorithm), atom reordering (fx. Hungarian algorithm), and axis reflections, 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

Citation

  • Implementation:

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

  • 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

Please cite this project when using it for scientific publications.

Installation

Easiest is to get the program vis PyPi under the package 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 calculate_rmsd.py 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 examples

Use calculate_rmsd --help to see all the features. 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 tests/ethane.xyz tests/ethane_translate.xyz

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

calculate_rmsd --no-hydrogen --print tests/ethane.xyz tests/ethane_mini.xyz

If the atoms are scrambled and not aligned you can use the --reorder argument which will align the atoms from structure B unto A. Use --reorder-method to select what method for reordering. Choose between Hungarian (default), distance (very approximate) and brute force (slow).

calculate_rmsd --reorder tests/water_16.xyz tests/water_16_idx.xyz

It is also possible to use RMSD as a library in other scripts, see example.py for example usage.

Problems?

Submit issues or pull requests on GitHub.

Contributions

Please note that we are using black with line length of 79. Easiest way to abide to the code standard is to install the following packages.

pip install black flake8 autoflake isort pytest

and

make format test lint

to auto-format and test the code.

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.4.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rmsd-1.4-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rmsd-1.4.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

File hashes

Hashes for rmsd-1.4.tar.gz
Algorithm Hash digest
SHA256 16a84a5f919faa0f2361e55ad4009a7c28e19a21ee9cc3bdb83f28ffb566563f
MD5 ae31b6705d9f0472fcbf3813627860e3
BLAKE2b-256 3a2ae77a00b4c8831d4e758603784f80dcc1e73fd0e8de7f73408d41bf59c186

See more details on using hashes here.

File details

Details for the file rmsd-1.4-py3-none-any.whl.

File metadata

  • Download URL: rmsd-1.4-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

File hashes

Hashes for rmsd-1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 659fd31dff39ef66c5c1c6b45ba9a91373151a8d88579e9f557a923435301e9c
MD5 e3d11d4e842b1ab4887d64a9de8420e4
BLAKE2b-256 08e7bcad7bf5a101d7e9359b91f15a10fad21c4a3140fb1df2893964de6ebd16

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