opencobra / memote

memote – the genome-scale metabolic model test suite
https://memote.readthedocs.io/
Apache License 2.0
125 stars 26 forks source link

"Biomass Production In Default Medium" test can produce NaN results, causing report rendering to error #636

Open kvikshaug opened 5 years ago

kvikshaug commented 5 years ago

We saw an occurrence in the online service where this test produced NaN values in the result object:

{
  'title': 'Biomass Production In Default Medium',
  'summary': '...',
  'format_type': 'number',
  'duration': {'reaction_id0': 0.0003418922424316406},
  'result': {'reaction_id0': 'skipped'},
  'metric': {'BIOMASS_Elim': 1.0, 'BIOMASS_Ecoli_core_w_GAM': 0.0},
  'score': {'BIOMASS_Elim': 0.0, 'BIOMASS_Ecoli_core_w_GAM': 1.0},
  'data': {'BIOMASS_Elim': nan, 'BIOMASS_Ecoli_core_w_GAM': 0.8739215069684279},
}

It looks like that was a result from the following function:

https://github.com/opencobra/memote/blob/8c4eabc1b48af6e24aa854f1b3543d5e7e2e2cf1/memote/suite/tests/test_biomass.py#L141

When calling report.render_json() on this result object, it raises ValueError: Out of range float values are not JSON compliant because json.dumps is called with allow_nan=False.

Unfortunately, the model that resulted in this report it is not available.