Skip to content

Commit

Permalink
Use symbols on --print (#121)
Browse files Browse the repository at this point in the history
* Use symbols on --print, instead of integers
  • Loading branch information
charnley authored Dec 23, 2024
1 parent 5ea5a21 commit b498c91
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- run: sudo apt-get install libopenblas-dev gcc
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ matplotlib
monkeytype
mypy
numpy
numpy
pre-commit
pylint
pytest
pytest-cov
qmllib
scipy
scipy
twine
9 changes: 6 additions & 3 deletions rmsd/calculate_rmsd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3

__doc__ = """
Calculate Root-mean-square deviation (RMSD) between structure A and B, in XYZ
or PDB format, using transformation and rotation.
Expand Down Expand Up @@ -1567,7 +1568,7 @@ def _parse_pdb_atom_line(line: str) -> Optional[str]:
return None


def _parse_pdb_coord_line(line: str):
def _parse_pdb_coord_line(line: str) -> Optional[ndarray]:
"""
Try my best to coordinates from a PDB ATOM or HETATOM line
Expand Down Expand Up @@ -2227,8 +2228,9 @@ def main(args: Optional[List[str]] = None) -> str:
if settings.print_only_rmsd_atoms or not use_view:
q_coord_sub = np.dot(q_coord_sub, U)
q_coord_sub += p_cent_sub
_atoms = np.asarray([str_atom(atom) for atom in q_atoms_sub])
return set_coordinates(
q_atoms_sub,
_atoms,
q_coord_sub,
title=f"Rotated '{settings.structure_b}' to match '{settings.structure_a}', with a RMSD of {result_rmsd:.8f}",
)
Expand All @@ -2244,8 +2246,9 @@ def main(args: Optional[List[str]] = None) -> str:

q_coord = np.dot(q_coord, U)
q_coord += p_cent_sub
_atoms = np.asarray([str_atom(atom) for atom in q_atoms])
return set_coordinates(
q_atoms,
_atoms,
q_coord,
title=f"Rotated {settings.structure_b} to match {settings.structure_a}, with RMSD of {result_rmsd:.8f}",
)
Expand Down
13 changes: 7 additions & 6 deletions tests/test_reorder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy

import numpy as np
from numpy import ndarray

import rmsd as rmsdlib

Expand All @@ -9,9 +10,9 @@ def test_reorder_distance() -> None:

N = 5
atoms = np.array(["H"] * N)
p_coord = np.arange(N * 3)
p_coord: ndarray = np.arange(N * 3)
p_coord = p_coord.reshape((5, 3))
q_coord = copy.deepcopy(p_coord)
q_coord = np.array(p_coord, copy=True)

np.random.seed(6)
np.random.shuffle(q_coord)
Expand All @@ -24,9 +25,9 @@ def test_reorder_distance() -> None:
def test_reorder_brute() -> None:
N = 5
atoms = np.array(["H"] * N)
p_coord = np.arange(N * 3)
p_coord: ndarray = np.arange(N * 3)
p_coord = p_coord.reshape((N, 3))
q_coord = copy.deepcopy(p_coord)
q_coord = np.array(p_coord, copy=True)

np.random.seed(6)
np.random.shuffle(q_coord)
Expand All @@ -41,7 +42,7 @@ def test_reorder_brute_ch() -> None:
p_atoms_str = ["C"] * 3 + ["H"] * 3
p_atoms_int = [rmsdlib.int_atom(atom) for atom in p_atoms_str]
p_atoms = np.array(p_atoms_int)
p_coord = np.arange(N * 3)
p_coord: ndarray = np.arange(N * 3)
p_coord = p_coord.reshape((N, 3))

# random index
Expand All @@ -65,7 +66,7 @@ def test_reorder_hungarian() -> None:

N = 5
atoms = np.array(["H"] * N)
p_coord = np.arange(N * 3)
p_coord: ndarray = np.arange(N * 3)
p_coord = p_coord.reshape((5, 3))
q_coord = copy.deepcopy(p_coord)

Expand Down

0 comments on commit b498c91

Please sign in to comment.