From 049c78b1f50622efe9b670b69e0b5cc8d2e561eb Mon Sep 17 00:00:00 2001 From: famosab Date: Wed, 2 Nov 2022 14:18:13 +0100 Subject: [PATCH] feat: example on how to integrate some tests from Memote #3 --- runner.py | 4 +++- tests/memote.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/memote.py diff --git a/runner.py b/runner.py index be9ff20..573b733 100644 --- a/runner.py +++ b/runner.py @@ -3,6 +3,7 @@ from os import environ import tests.cobra import tests.yaml +import tests.memote API_ENDPOINT = 'https://api.github.com/graphql' API_TOKEN = environ['GH_TOKEN'] @@ -89,9 +90,10 @@ def validate(nameWithOwner): file.write(response.text) test_results.update(tests.yaml.validate(model)) test_results.update(tests.cobra.validate(model)) + test_results.update(tests.memote.get_consistency(model)) else: print('is not following standard') release_data = { 'standard-GEM' : [ { standard_version : gem_is_standard }, { 'test_results' : test_results} ] } data[nameWithOwner].append({ model_release: release_data }) with open('results/{}_{}.json'.format(owner, model), 'w') as output: - output.write(json.dumps(data, indent=2, sort_keys=True)) + output.write(json.dumps(data, indent=2, sort_keys=True)) \ No newline at end of file diff --git a/tests/memote.py b/tests/memote.py new file mode 100644 index 0000000..78f9917 --- /dev/null +++ b/tests/memote.py @@ -0,0 +1,17 @@ +import memote +import cobra +import json +from memote.support import consistency +# needed by memote.support.consitency +from memote.support import consistency_helpers as con_helpers + +def get_consistency(model_filename): + try: + model = cobra.io.read_sbml_model(model_filename + '.xml') + except Exception as e: + errors = json.dumps(str(e)) + print(e) + + is_consistent = consistency.check_stoichiometric_consistency(model) + + return {'memote-tests': { memote.__version__ : is_consistent, 'errors': errors } } \ No newline at end of file