Skip to content

Commit 049c78b

Browse files
committed
feat: example on how to integrate some tests from Memote #3
1 parent ba5b395 commit 049c78b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

runner.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from os import environ
44
import tests.cobra
55
import tests.yaml
6+
import tests.memote
67

78
API_ENDPOINT = 'https://api.github.com/graphql'
89
API_TOKEN = environ['GH_TOKEN']
@@ -89,9 +90,10 @@ def validate(nameWithOwner):
8990
file.write(response.text)
9091
test_results.update(tests.yaml.validate(model))
9192
test_results.update(tests.cobra.validate(model))
93+
test_results.update(tests.memote.get_consistency(model))
9294
else:
9395
print('is not following standard')
9496
release_data = { 'standard-GEM' : [ { standard_version : gem_is_standard }, { 'test_results' : test_results} ] }
9597
data[nameWithOwner].append({ model_release: release_data })
9698
with open('results/{}_{}.json'.format(owner, model), 'w') as output:
97-
output.write(json.dumps(data, indent=2, sort_keys=True))
99+
output.write(json.dumps(data, indent=2, sort_keys=True))

tests/memote.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import memote
2+
import cobra
3+
import json
4+
from memote.support import consistency
5+
# needed by memote.support.consitency
6+
from memote.support import consistency_helpers as con_helpers
7+
8+
def get_consistency(model_filename):
9+
try:
10+
model = cobra.io.read_sbml_model(model_filename + '.xml')
11+
except Exception as e:
12+
errors = json.dumps(str(e))
13+
print(e)
14+
15+
is_consistent = consistency.check_stoichiometric_consistency(model)
16+
17+
return {'memote-tests': { memote.__version__ : is_consistent, 'errors': errors } }

0 commit comments

Comments
 (0)