Skip to content

Commit

Permalink
fix: integration tests (#390)
Browse files Browse the repository at this point in the history
* expect 12 files because of 0_setup

* fix: impropers were not correctly removed in break_bond

* fuck this bug

* remove debug lines

---------

Co-authored-by: Eric Hartmann <hartmaec@rh05659.villa-bosch.de>
  • Loading branch information
ehhartmann and Eric Hartmann committed Feb 27, 2024
1 parent d791518 commit 526d888
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
33 changes: 20 additions & 13 deletions src/kimmdy/topology/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,11 @@ def _get_atom_improper_dihedrals(
ai = atom_nr
partners = self.atoms[ai].bound_to_nrs
if len(partners) >= 3:
for aj, ak, al in combinations(partners, 3):
dihedral_candidate_keys.append((ai, aj, ak, al))
combs = permutations(partners, 3)
for comb in combs:
aj, ak, al = comb
# center atom is at position 3
dihedral_candidate_keys.append((aj, ak, ai, al))

# atom in corner of a triangle:
for a in self.atoms[atom_nr].bound_to_nrs:
Expand Down Expand Up @@ -1130,12 +1133,12 @@ def break_bond(
reactive_moleculetype.pairs.pop(pairkey, None)

# and improper dihedrals
dihedral_k_v = reactive_moleculetype._get_atom_improper_dihedrals(
atompair_nrs[0], self.ff
) + reactive_moleculetype._get_atom_improper_dihedrals(atompair_nrs[1], self.ff)
for key, _ in dihedral_k_v:
keys_remove = []
for key in reactive_moleculetype.improper_dihedrals:
if all([x in key for x in atompair_nrs]):
reactive_moleculetype.improper_dihedrals.pop(key, None)
keys_remove.append(key)
for key in keys_remove:
reactive_moleculetype.improper_dihedrals.pop(key, None)

# warn if atom is part of restraint
for atom in atompair:
Expand Down Expand Up @@ -1221,7 +1224,7 @@ def bind_bond(
for a in reactive_moleculetype.atoms.values()
if a.resnr == other_atom.resnr
]
type_set = False
name_set = False
for key, bond in aa.bonds.items():
if other_atom.atom in key and any(
k.upper().startswith("H") for k in key
Expand All @@ -1237,21 +1240,25 @@ def bind_bond(
or h_name == atom.atom
):
atom.atom = h_name
name_set = True
else:
atom.atom = "HX"
type_set = True
name_set = True
continue
logging.info(f"HAT hydrogen will be bound to {other_atom}.")
logger.info(f"HAT hydrogen will be bound to {other_atom}.")
break
else:
if type_set:
logging.warning(
if name_set:
logger.warning(
"Found new atomtype but not atomname for HAT hydrogen!"
)
else:
logging.warning(
logger.warning(
"Found neither new atomtype nor atomname for HAT hydrogen!"
)
if not name_set:
atom.atom = "HX"
logger.warning(f"Named newly bonded hydrogen 'HX'")

# update bound_to
atompair[0].bound_to_nrs.append(atompair[1].nr)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_integration_homolysis_reaction(arranged_tmp_path):
def test_integration_pull(arranged_tmp_path):
kimmdy_run()
assert "Finished running tasks" in read_last_line(Path("kimmdy.log"))
assert len(list(Path.cwd().glob("kimmdy_001/*"))) == 11
assert len(list(Path.cwd().glob("kimmdy_001/*"))) == 12


@pytest.mark.require_grappa
Expand All @@ -117,4 +117,4 @@ def test_integration_pull(arranged_tmp_path):
def test_integration_whole_run(arranged_tmp_path):
kimmdy_run()
assert "Finished running tasks" in read_last_line(Path("kimmdy.log"))
assert len(list(Path.cwd().glob("*/*"))) == 23
assert len(list(Path.cwd().glob("kimmdy_001/*"))) == 25

0 comments on commit 526d888

Please sign in to comment.