Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbuhr committed Mar 6, 2024
1 parent 0f39b87 commit e54549e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
9 changes: 6 additions & 3 deletions tests/test_parsing.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import re
import string
import pytest
from hypothesis import settings, HealthCheck, given, strategies as st
from pathlib import Path

import pytest
from hypothesis import HealthCheck, given, settings
from hypothesis import strategies as st

from kimmdy import parsing
from kimmdy.utils import get_gmx_dir
from kimmdy.constants import AA3
from kimmdy.utils import get_gmx_dir


## test topology parser
Expand Down Expand Up @@ -40,6 +42,7 @@ def test_doubleparse_urea(arranged_tmp_path):
def test_ff_includes_with_gmxdir(arranged_tmp_path):
top_dict = parsing.read_top(Path("urea.top"))
gmx_dir = get_gmx_dir("gmx")
assert gmx_dir is not None, "gmx dir not found"
tip3_dict = parsing.read_top(gmx_dir / "top" / "amber99.ff" / "tip3p.itp")

assert top_dict["atomtypes"]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ def test_place_initialization():
assert m2 != m3

with pytest.raises(TypeError):
recipe.Place(ix_to_place=1)
recipe.Place(ix_to_place=1) # type: ignore
with pytest.raises(ValueError):
recipe.Place(id_to_place=1, new_coords=(0, 0, 0))
recipe.Place(id_to_place=1, new_coords=(0, 0, 0)) # type: ignore


def test_relax_initialization():
Expand Down
16 changes: 10 additions & 6 deletions tests/test_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ def test_del_atom_hexala(self, hexala_top_fix, atomindex):
for a_del in angles_to_delete:
assert None in [update.get(a) for a in a_del]
for a_up in angles_to_update:
new = top.angles[tuple([update.get(a) for a in a_up])]
k1, k2, k3 = [update[a] for a in a_up]
new = top.angles[k1, k2, k3]
old = hexala_top_fix.angles[a_up]
assert old.ai == rev_update.get(new.ai)
assert old.aj == rev_update.get(new.aj)
Expand All @@ -341,7 +342,8 @@ def test_del_atom_hexala(self, hexala_top_fix, atomindex):
for pd_del in pd_to_delete:
assert None in tuple([update.get(a) for a in pd_del])
for pd_up in pd_to_update:
new = top.proper_dihedrals[tuple([update.get(a) for a in pd_up])]
k1, k2, k3, k4 = [update[a] for a in pd_up]
new = top.proper_dihedrals[k1, k2, k3, k4]
old = hexala_top_fix.proper_dihedrals[pd_up]
assert old.ai == rev_update.get(new.ai)
assert old.aj == rev_update.get(new.aj)
Expand All @@ -360,7 +362,8 @@ def test_del_atom_hexala(self, hexala_top_fix, atomindex):
for id_del in id_to_delete:
assert None in tuple([update.get(a) for a in id_del])
for id_up in id_to_update:
new = top.improper_dihedrals[tuple([update.get(a) for a in id_up])]
k1, k2, k3, k4 = [update[a] for a in id_up]
new = top.improper_dihedrals[k1, k2, k3, k4]
old = hexala_top_fix.improper_dihedrals[id_up]
assert old.ai == rev_update.get(new.ai)
assert old.aj == rev_update.get(new.aj)
Expand Down Expand Up @@ -637,9 +640,10 @@ def test_top_update_dict(self, raw_hexala_top_fix):
assert raw["moleculetype_Protein"]["content"][0] == ["Protein", "3"]
assert top.top["moleculetype_Reactive"]["content"][0] == ["Reactive", "3"]
for section in ["atoms", "bonds", "angles", "dihedrals", "pairs"]:
top.top["moleculetype_Reactive"]["subsections"][section]["content"] == raw[
"moleculetype_Protein"
]["subsections"][section]["content"]
assert (
top.top["moleculetype_Reactive"]["subsections"][section]["content"]
== raw["moleculetype_Protein"]["subsections"][section]["content"]
)

def test_top_properties(self, hexala_top_fix):
top = deepcopy(hexala_top_fix)
Expand Down

0 comments on commit e54549e

Please sign in to comment.