From ab0a17d9988b361fa30682d10c35a12e7f0efb41 Mon Sep 17 00:00:00 2001 From: Helen G Scott Date: Wed, 25 Oct 2023 10:29:07 -0400 Subject: [PATCH 1/3] Use find met in model function to check for metanetx IDs --- src/memote/suite/tests/test_consistency.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/memote/suite/tests/test_consistency.py b/src/memote/suite/tests/test_consistency.py index 48e84ee8..b1676ec0 100644 --- a/src/memote/suite/tests/test_consistency.py +++ b/src/memote/suite/tests/test_consistency.py @@ -24,6 +24,7 @@ import memote.support.consistency as consistency import memote.support.consistency_helpers as con_helpers +import memote.support.helpers as helpers from memote.utils import annotate, get_ids, truncate, wrapper @@ -153,7 +154,8 @@ def test_detect_energy_generating_cycles(model, met): """ ann = test_detect_energy_generating_cycles.annotation - if met not in model.metabolites: + main_comp = helpers.find_compartment_id_in_model(model, "c") + if helpers.find_met_in_model(model, met, main_comp)[0] is None: pytest.skip( "This test has been skipped since metabolite {} could " "not be found in the model.".format(met) From 2be2d2fbb1aea20efb0358d7ada2c5555c7724ad Mon Sep 17 00:00:00 2001 From: Helen G Scott Date: Thu, 26 Oct 2023 15:45:17 -0400 Subject: [PATCH 2/3] Use try and except to catch metabolites that are missing --- src/memote/suite/tests/test_consistency.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/memote/suite/tests/test_consistency.py b/src/memote/suite/tests/test_consistency.py index b1676ec0..1d4b4698 100644 --- a/src/memote/suite/tests/test_consistency.py +++ b/src/memote/suite/tests/test_consistency.py @@ -154,12 +154,16 @@ def test_detect_energy_generating_cycles(model, met): """ ann = test_detect_energy_generating_cycles.annotation + # Test if the metabolite is present in the model. main_comp = helpers.find_compartment_id_in_model(model, "c") - if helpers.find_met_in_model(model, met, main_comp)[0] is None: + try: + helpers.find_met_in_model(model, met, main_comp)[0] + except: pytest.skip( "This test has been skipped since metabolite {} could " "not be found in the model.".format(met) ) + # If the metabolite is present, carry out the test. ann["data"][met] = consistency.detect_energy_generating_cycles(model, met) # Report the number of cycles scaled by the number of reactions. ann["metric"][met] = len(ann["data"][met]) / len(model.reactions) From 3e505ca1ad4389eeaead88489f64c131ea15ed58 Mon Sep 17 00:00:00 2001 From: Helen G Scott Date: Fri, 3 Nov 2023 14:26:18 -0400 Subject: [PATCH 3/3] Add explicit exceptions Co-authored-by: Moritz E. Beber --- src/memote/suite/tests/test_consistency.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/memote/suite/tests/test_consistency.py b/src/memote/suite/tests/test_consistency.py index 1d4b4698..6e4548a4 100644 --- a/src/memote/suite/tests/test_consistency.py +++ b/src/memote/suite/tests/test_consistency.py @@ -158,7 +158,9 @@ def test_detect_energy_generating_cycles(model, met): main_comp = helpers.find_compartment_id_in_model(model, "c") try: helpers.find_met_in_model(model, met, main_comp)[0] - except: + except ValueError: + pytest.skip("Metabolite {} is not in the MetaNetX shortlist.".format(met)) + except (RuntimeError, IndexError): pytest.skip( "This test has been skipped since metabolite {} could " "not be found in the model.".format(met)