From 7f830c8fd8e4a53e28365cbbd340c15f92a20122 Mon Sep 17 00:00:00 2001 From: "David W.H. Swenson" Date: Tue, 26 Sep 2023 14:29:02 -0500 Subject: [PATCH] Improve error message if missing one leg for ligand pair (#568) --- openfecli/commands/gather.py | 6 ++++-- openfecli/tests/commands/test_gather.py | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/openfecli/commands/gather.py b/openfecli/commands/gather.py index 7b9e466e0..704a14e29 100644 --- a/openfecli/commands/gather.py +++ b/openfecli/commands/gather.py @@ -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)) diff --git a/openfecli/tests/commands/test_gather.py b/openfecli/tests/commands/test_gather.py index 416bcfec7..ca71e6acc 100644 --- a/openfecli/tests/commands/test_gather.py +++ b/openfecli/tests/commands/test_gather.py @@ -2,6 +2,7 @@ import glob from importlib import resources import tarfile +import pathlib import pytest from openfecli.commands.gather import ( @@ -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)