SBRG / bigg_models

The BiGG Models website server
http://bigg.ucsd.edu
Other
80 stars 18 forks source link

Universal (JSON) model does not follow COBRA JSON schema #374

Open bdelepine opened 3 years ago

bdelepine commented 3 years ago

BiGG provide a very handy universal model at : http://bigg.ucsd.edu/data_access The JSON format is supposed to be a COBRA-compliant model, however it does not respect the schema from : https://github.com/opencobra/cobrapy/blob/devel/src/cobra/io/schema_v1.json

import json
from jsonschema import validate

with open("universal_model.json", 'r') as hdl, open("schema_v1.json", 'r') as hdl2:
    instance = json.load(hdl)
    schema = json.load(hdl2)

validate(instance, schema)

Will yield the following error:

ValidationError: [['RHEA', 'http://identifiers.org/rhea/35071'], ['RHEA', 'http://identifiers.org/rhea/35072'], ['RHEA', 'http://identifiers.org/rhea/35073'], ['RHEA', 'http://identifiers.org/rhea/35074'], ['BioCyc', 'http://identifiers.org/biocyc/META:TRANS-RXN0-500'], ['MetaNetX (MNX) Equation', 'http://identifiers.org/metanetx.reaction/MNXR96888']] is not of type 'object'

Failed validating 'type' in schema['properties']['reactions']['items']['properties']['annotation']:
    {'type': 'object'}

On instance['reactions'][0]['annotation']:
    [['RHEA', 'http://identifiers.org/rhea/35071'],
     ['RHEA', 'http://identifiers.org/rhea/35072'],
     ['RHEA', 'http://identifiers.org/rhea/35073'],
     ['RHEA', 'http://identifiers.org/rhea/35074'],
     ['BioCyc', 'http://identifiers.org/biocyc/META:TRANS-RXN0-500'],
     ['MetaNetX (MNX) Equation',
      'http://identifiers.org/metanetx.reaction/MNXR96888']]

This is also visible if you try to import the model using cobra (cobra.io.load_json_model("universal_model.json"), tested on version 0.20.0): you will get a TypeError: Annotation must be a dict.

Midnighter commented 3 years ago

Sadly, this is actually more cobrapy's fault. The schema was for a long time fairly loosely defined (and still is not extremely tight) but then we introduced a change without adding a new version.

bdelepine commented 3 years ago

Thanks for your answer. I just saw that the same issue is also reported in the cobra repo: https://github.com/opencobra/cobrapy/issues/1012

I would naively consider that the schema provided by cobra is de facto the new standard and that projects relying on cobra should now adapt (even if it is an unexpected breaking change).

@Midnighter which issue should be closed?

Midnighter commented 3 years ago

Yes, we would hope that projects will adapt over time but we should have created a new version and not break the format for an existing version. That was poor form. I'd definitely like to keep the issue on cobrapy open. For the one here, it is up to the repo owners if they want to keep it open in order to track progress.

pstjohn commented 3 years ago

Just in case it helps, I'm able to load universal_model.json with 0.17.1, but not 0.18.1