Skip to content

Commit

Permalink
Improve error message if missing one leg for ligand pair (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwhswenson authored Sep 26, 2023
1 parent f403763 commit 7f830c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions openfecli/commands/gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ def _get_ddgs(legs):
if not ((DG1_mag is None) or (DG2_mag is None)):
DDGhyd = (DG1_mag - DG2_mag).m
hyd_unc = np.sqrt(np.sum(np.square([DG1_unc.m, DG2_unc.m])))
else: # -no-cov-
raise RuntimeError(f"Unknown DDG type for {vals}")
else:
raise RuntimeError("Unable to determine type of RFE calculation "
f"for edges with labels {list(vals)} for "
f"ligands {ligpair}")

DDGs.append((*ligpair, DDGbind, bind_unc, DDGhyd, hyd_unc))

Expand Down
13 changes: 13 additions & 0 deletions openfecli/tests/commands/test_gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import glob
from importlib import resources
import tarfile
import pathlib
import pytest

from openfecli.commands.gather import (
Expand Down Expand Up @@ -106,3 +107,15 @@ def test_gather(results_dir, report):

assert set(expected.split(b'\n')) == actual_lines


def test_missing_leg_error(results_dir):
file_to_remove = "easy_rbfe_lig_ejm_31_complex_lig_ejm_42_complex.json"
(pathlib.Path("results") / file_to_remove).unlink()

runner = CliRunner()
result = runner.invoke(gather, ['results'] + ['-o', '-'])
assert result.exit_code == 1
assert isinstance(result.exception, RuntimeError)
assert "labels ['solvent']" in str(result.exception)
assert "'lig_ejm_31'" in str(result.exception)
assert "'lig_ejm_42'" in str(result.exception)

0 comments on commit 7f830c8

Please sign in to comment.