Skip to content

Commit

Permalink
Merge pull request #34 from RMeli/develop
Browse files Browse the repository at this point in the history
Publication and Minor Improvements
  • Loading branch information
RMeli authored Sep 6, 2020
2 parents 09b7211 + 5ab1f53 commit 324ddb3
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ["https://www.buymeacoffee.com/rmeli"]
custom: # ["https://www.buymeacoffee.com/rmeli"]
54 changes: 54 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "CodeQL"

on:
push:
branches: [develop, master]
pull_request:
# The branches below must be a subset of the branches above
branches: [develop]
schedule:
- cron: '0 0 * * 3'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,31 @@
[![Docs](https://img.shields.io/badge/docs-spyrmsd.readthedocs.io-blueviolet)](https://spyrmsd.readthedocs.io)
[![Documentation Status](https://readthedocs.org/projects/spyrmsd/badge/?version=develop)](https://spyrmsd.readthedocs.io/en/develop/?badge=develop)

[![DOI](https://zenodo.org/badge/214157073.svg)](https://zenodo.org/badge/latestdoi/214157073)
[![License](https://img.shields.io/github/license/RMeli/pyrmsd?color=%2333BBFF)](https://opensource.org/licenses/MIT)
[![PyPI](https://img.shields.io/badge/PyPI-v0.3.3%20-ff69b4)](https://pypi.org/project/spyrmsd/)
[![PyPI](https://img.shields.io/badge/PyPI-v0.3.5%20-ff69b4)](https://pypi.org/project/spyrmsd/)
[![Conda Version](https://img.shields.io/conda/vn/conda-forge/spyrmsd.svg)](https://anaconda.org/conda-forge/spyrmsd)

[![J. Cheminform.](https://img.shields.io/badge/J.%20Cheminform.-10.1186%2Fs13321--020--00455--2-blue)](https://doi.org/10.1186/s13321-020-00455-2)
[![Zenodo](https://zenodo.org/badge/214157073.svg)](https://zenodo.org/badge/latestdoi/214157073)

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](https://pypi.org/project/spyrmsd/) and [conda-forge](https://github.com/conda-forge/spyrmsd-feedstock) and can be easily installed from source. See [Dependencies](###Dependencies) for a description of all the dependencies.
Expand Down Expand Up @@ -56,7 +74,7 @@ The following packages are required to use `spyrmsd` as a module:
* [scipy](https://www.scipy.org/)
* [qcelemental](http://docs.qcarchive.molssi.org/projects/qcelemental/en/latest/)

_Note_: `spyrmsd` uses [graph-tool](https://graph-tool.skewed.de/) by default but will fall back to [NetworkX](https://networkx.github.io/) if the former is not installed (e.g. on Windows).
_Note_: `spyrmsd` uses [graph-tool](https://graph-tool.skewed.de/) by default but will fall back to [NetworkX](https://networkx.github.io/) if the former is not installed (e.g. on Windows). However, in order to support cross-platform installation [NetworkX](https://networkx.github.io/) is installed by default.

#### Standalone Tool

Expand All @@ -65,7 +83,7 @@ Additionally, one of the following packages is required to use `spyrmsd` as a st
* [Open Babel](http://openbabel.org/)
* [RDKit](https://rdkit.org/)

_Note_: [RDKit](https://rdkit.org/) has to be installed using `conda` ([Why the RDKit isn't available on PyPi](https://rdkit.blogspot.com/2019/11/why-rdkit-isnt-available-on-pypi.html)).
_Note_: [RDKit](https://rdkit.org/) is not available on PyPI ([Why the RDKit isn't available on PyPi](https://rdkit.blogspot.com/2019/11/why-rdkit-isnt-available-on-pypi.html)). See [RDKit Installation](http://www.rdkit.org/docs/Install.html) for installation instructions.

## Usage

Expand All @@ -76,8 +94,7 @@ python -m spyrmsd.spyrmsd -h
```

```text
usage: spyrmsd.py [-h] [-m] [-c] [--hydrogens] [-n]
reference molecules [molecules ...]
usage: spyrmsd.py [-h] [-m] [-c] [--hydrogens] [-n] reference molecules [molecules ...]
Python RMSD tool.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dist-name = "spyrmsd"
description-file = "README.md"
author = "Rocco Meli"
author-email = "[email protected]"
home-page = "https://pyrmsd.readthedocs.io"
home-page = "https://spyrmsd.readthedocs.io"
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",]
Expand Down
10 changes: 8 additions & 2 deletions spyrmsd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Python RMSD tool with symmetry correction.
"""

from .due import due, Doi
from ._version import get_versions
from .due import Doi, due

versions = get_versions()
__version__ = versions["version"]
Expand All @@ -14,5 +14,11 @@
due.cite(
Doi("10.5281/zenodo.3631876"), # lgtm[py/procedure-return-value-used]
path="spyrmsd",
description="spyRMSD: Symmetry-Corrected RMSD in Python",
description="spyrmsd",
)

due.cite(
Doi("10.1186/s13321-020-00455-2"), # lgtm[py/procedure-return-value-used]
path="spyrmsd",
description="spyrmsd",
)
5 changes: 4 additions & 1 deletion spyrmsd/graphs/gt.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ def match_graphs(G1, G2) -> List[Tuple[List[int], List[int]]]:
# Check if graphs are actually isomorphic
if len(maps) == 0:
# TODO: Create a new exception
raise ValueError(f"Graphs {G1} and {G2} are not isomorphic.")
raise ValueError(
"Graphs are not isomorphic."
"\nMake sure graphs have the same connectivity."
)

n = num_vertices(G1)

Expand Down
5 changes: 4 additions & 1 deletion spyrmsd/graphs/nx.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ def match_atomicnum(node1, node2):
# Check if graphs are actually isomorphic
if not GM.is_isomorphic():
# TODO: Create a new exception
raise ValueError(f"Graphs {G1} and {G2} are not isomorphic.")
raise ValueError(
"Graphs are not isomorphic."
"\nMake sure graphs have the same connectivity."
)

return [
(list(isomorphism.keys()), list(isomorphism.values()))
Expand Down
2 changes: 1 addition & 1 deletion spyrmsd/hungarian.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import scipy

from .due import due, Doi
from .due import Doi, due

due.cite(
Doi("10.1021/ci400534h"), # lgtm[py/procedure-return-value-used]
Expand Down
2 changes: 1 addition & 1 deletion spyrmsd/qcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
from scipy import optimize

from .due import due, Doi
from .due import Doi, due

due.cite(
Doi("10.1107/S0108767305015266"), # lgtm[py/procedure-return-value-used]
Expand Down
20 changes: 11 additions & 9 deletions tests/test_rmsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,34 +219,36 @@ def test_rmsd_hungarian_benzene_rotated(angle: float, tol: float) -> None:
) == pytest.approx(0, abs=tol)


@pytest.mark.parametrize("d", [-0.5, 0.0, 0.5, 1.0, 1.5])
@pytest.mark.parametrize(
"angle, tol", [(60, 1e-4), (120, 1e-4), (180, 1e-4), (240, 1e-4), (300, 1e-4)]
)
def test_rmsd_hungarian_benzene_shifted_rotated(angle: float, tol: float) -> None:
def test_rmsd_hungarian_benzene_shifted_rotated(
d: float, angle: float, tol: float
) -> None:

mol1 = copy.deepcopy(molecules.benzene)
mol2 = copy.deepcopy(molecules.benzene)

mol2.translate([0, 0, 1])
mol2.translate([0, 0, d])

assert rmsd.rmsd(
mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums
) == pytest.approx(1)
) == pytest.approx(abs(d))

assert rmsd.hrmsd(
mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums
) == pytest.approx(1)
) == pytest.approx(abs(d))

# Rotations different than 180 degrees introduce numerical errors (~1e-11)
mol2.rotate(angle, [0, 0, 1], units="deg")

assert (
rmsd.rmsd(mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums)
> 1
)
assert rmsd.rmsd(
mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums
) > abs(d)
assert rmsd.hrmsd(
mol1.coordinates, mol2.coordinates, mol1.atomicnums, mol2.atomicnums
) == pytest.approx(1, abs=tol)
) == pytest.approx(abs(d), abs=tol)


@pytest.mark.parametrize("mol", molecules.allmolecules)
Expand Down

0 comments on commit 324ddb3

Please sign in to comment.