From 516a3aeb55c2bb06e6ae7d63e2d04affbae4a92d Mon Sep 17 00:00:00 2001 From: richard gowers Date: Mon, 3 Jul 2023 12:07:52 +0100 Subject: [PATCH] allow gathering of legacy results --- openfecli/commands/gather.py | 24 +++++++++++++++++++++--- openfecli/tests/commands/test_gather.py | 1 - 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/openfecli/commands/gather.py b/openfecli/commands/gather.py index b86d16e7..b4cd7bfa 100644 --- a/openfecli/commands/gather.py +++ b/openfecli/commands/gather.py @@ -23,7 +23,10 @@ def get_names(result) -> tuple[str, str]: # Result to tuple of ligand names nm = list(result['unit_results'].values())[0]['name'] toks = nm.split() - return toks[0], toks[2] + if toks[2] == 'repeat': + return toks[0], toks[1] + else: + return toks[0], toks[2] def get_type(res): @@ -39,6 +42,15 @@ def get_type(res): return 'solvent' +def legacy_get_type(res_fn): + if 'solvent' in res_fn: + return 'solvent' + elif 'vacuum' in res_fn: + return 'vacuum' + else: + return 'complex' + + @click.command( 'gather', short_help="Gather result jsons for network of RFE results into a TSV file" @@ -104,8 +116,14 @@ def gather(rootdir, output): click.echo(f"WARNING: Calculations for {result_fn} did not finish succesfully!", err=True) - names = get_names(result) - simtype = get_type(result) + try: + names = get_names(result) + except KeyError: + raise ValueError("Failed to guess names") + try: + simtype = get_type(result) + except KeyError: + simtype = legacy_get_type(result_fn) legs[names][simtype] = result['estimate'], result['uncertainty'] diff --git a/openfecli/tests/commands/test_gather.py b/openfecli/tests/commands/test_gather.py index 9e29327c..afafc4e2 100644 --- a/openfecli/tests/commands/test_gather.py +++ b/openfecli/tests/commands/test_gather.py @@ -69,7 +69,6 @@ DGvacuum(lig_13, lig_14)\tvacuum\tlig_13\tlig_14\t15.0\t0.0057 """ -@pytest.mark.xfail def test_gather(results_dir, ref_gather): runner = CliRunner()