Skip to main content

sPyRMSD

pytest flake8 mypy codecov

Docs Documentation Status

License PyPI Conda Version

J. Cheminform. Zenodo

Python tool for symmetry-corrected RMSD calculations.


If you find spyrmsd useful, please consider citing the following paper:

@article{spyrmsd2020,
  Author = {Meli, Rocco and Biggin, Philip C.},
  Journal = {Journal of Cheminformatics},
  Number = {1},
  Pages = {49},
  Title = {spyrmsd: symmetry-corrected RMSD calculations in Python},
  Volume = {12},
  Year = {2020}
}

Installation

spyrmsd is available on PyPI and conda-forge and can be easily installed from source. See Dependencies for a description of all the dependencies.

[!NOTE] spyrmsd will install rustworkx (multi-platform) when using pip or conda. You can install other backends manually.

[!WARNING] If spyrmsd is used as a standalone tool, it is required to install either RDKit or Open Babel. Neither is automatically installed with pip nor conda.

PyPI

pip install spyrmsd

conda

conda install spyrmsd -c conda-forge

GitHub

git clone https://github.com/RMeli/spyrmsd.git
cd spyrmsd
pip install .

Dependencies

spyrmsd can be used both as a module or as a standalone tool.

Module

The following packages are required to use spyrmsd as a module:

One of the following graph libraries is required:

[!NOTE] spyrmsd uses the following priority when multiple graph libraries are present: graph-tool, rustworkx, NetworkX. This order might change. Use set_backend to ensure you are always using the same backend, if needed.

Standalone Tool

Additionally, one of the following packages is required to use spyrmsd as a standalone tool:

Usage

Standalone Tool

spyrmsd provides a convenient CLI tool. See spyrmsd's --help for the usage:

python -m spyrmsd -h

Module

from spyrmsd import rmsd

RMSD

The function rmsd.rmsd computes RMSD without symmetry correction. The atoms are expected to be in the same order for both molecules being compared (no atom matching is performed).

def rmsd(
    coords1: np.ndarray,    # Coordinates of molecule 1
    coords2: np.ndarray,    # Coordinates of molecule 2
    aprops1: np.ndarray,    # Atomic properties of molecule 1
    aprops2: np.ndarray,    # Atomic properties of molecule 2
    center: bool = False,   # Flag to center molecules at origin
    minimize: bool = False, # Flag to compute minimum RMSD
    atol: float = 1e-9,     # Numerical tolerance for QCP method
)

[!NOTE] Atomic properties (aprops) can be any Python object when using NetworkX and rustworkx, or integers, floats, or strings when using graph-tool.

Symmetry-Corrected RMSD

The function rmsd.symmrmsd computes symmetry-corrected RMSD using molecular graph isomorphisms. Symmetry correction requires molecular adjacency matrices describing the connectivity but needs not the atoms to be in the same order.

Atom matching is performed according to the molecular graph. This function should also be used when atoms in the molecules being compared are not in the same order (even if there is not symmetry to be accounted for).

def symmrmsd(
    coordsref: np.ndarray,                       # Reference coordinated
    coords: Union[np.ndarray, List[np.ndarray]], # Coordinates (one set or multiple sets)
    apropsref: np.ndarray,                       # Reference atomic properties
    aprops: np.ndarray,                          # Atomic properties
    amref: np.ndarray,                           # Reference adjacency matrix
    am: np.ndarray,                              # Adjacency matrix
    center: bool = False,                        # Flag to center molecules at origin
    minimize: bool = False,                      # Flag to compute minimum RMSD
    cache: bool = True,                          # Cache graph isomorphisms
    atol: float = 1e-9,                          # Numerical tolerance for QCP method
)

[!NOTE] Atomic properties (aprops) can be any Python object when using NetworkX and rustworkx, or integers, floats, or strings when using graph-tool.

Select Backend

spyrmsd supports the following graph libraries for the calculation of graph isomorphisms:

You can check which backend is being used with

spyrmsd.get_backend()

You can also manually select your preferred backend with

spyrmsd.set_backend("networkx")
# spyrmsd uses NetworkX
spyrmsd.set_backend("graph_tool")
# spyrmsd uses graph_tool

The available backends (which depend on the installed dependencies) are stored in spyrmsd.available_backends.

Development

To ensure code quality and consistency the following tools are used during development:

Pre-commit git hooks can be installed with pre-commit.

Copyright

Copyright (c) 2019-2024, Rocco Meli.

References

References are tracked with duecredit. Run the credits.sh script in order to print up-to-date references.

Acknowledgements

Project based on the Computational Molecular Science Python Cookiecutter version 1.1.

Release files for spyrmsd 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spyrmsd 0.9.0
File Size Uploaded
spyrmsd-0.9.0.tar.gz 224.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spyrmsd 0.9.0
File Interpreter ABI Platform
spyrmsd-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 255.6 kB

Release files / spyrmsd-0.9.0.tar.gz

Download URL spyrmsd-0.9.0.tar.gz
Size 224.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4040eb6b4fc7c562ef4cae9b0780462ddefecce63f34f4a497b1336ca0fd658a
BLAKE2b-256 checksum
How to use checksums
19c25c89204e49ec165317d2b55ae9eed57101cefcb33a3673a38fd28ed0272b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Release files / spyrmsd-0.9.0-py3-none-any.whl

Download URL spyrmsd-0.9.0-py3-none-any.whl
Size 30.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
961170884223bf7a9f50204b792600e48fb023403efd3d01f0406ffda26da94e
BLAKE2b-256 checksum
How to use checksums
dc8768a40c790c280af35be6ad33d3f878ba14d2be2ed39b401c2e2576514f84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page