opencobra / memote

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

MeMote not reading valid Level 3 Version 1 SBML yet not reading annotations as Level 3 Version 2 #723

Closed Wheaties91 closed 2 years ago

Wheaties91 commented 2 years ago

The issue I am having is that the online version of MeMote continues to give the following error whenever I upload the attached model (file iTSA382_l3v1.txt):

"Something went wrong reading the SBML model. Most likely the SBML model is not valid. Please check that your model is valid using the cobra.io.sbml.validate_sbml_model function or via the online validator at http://sbml.org/validator . (model, errors) = validate_sbml_model(filename) If the model is valid and cannot be read please open an issue at https://github.com/opencobra/cobrapy/issues ."

However, this model passes the online sbml validator found at http://sbml.org/validator/ (only returning 527 Warnings related to Modeling Practice Guideline #80601).

Much of the annotation is inside the fbc framework. The model will be analyzed by MeMote as a Level 3 Version 2 (essentially all I need to do is update the version references and remove the "fast" attributes of all reactions). Unfortunately, as a Level 3 Version 2 SBML, I find that MeMote cannot read the fbc framework and returns an artificially low mode score (attached file iTSA382_l3v2.txt). Specifically, all metabolites are read as having neither charge nor formula, in addition to the gene being read as without annotation. This persists even though it is clearly the case that charges, formulas, and gene annotation exists.

A speedy resolution to this issue would be much appreciated, as I am looking to demonstrate I have a strong base model before expanding on it.

Thank you for you time, effort, and expertise, Wheaton

iTSA382_l3v1.txt iTSA382_l3v2.txt

draeger commented 2 years ago

@Wheaties91: As a quick solution, you could install Memote locally and run it yourself. That's what I do when receiving this error.

An additional note: To get rid of the warnings, you could also set the initial amounts of all species and all compartment sizes to NaN (not a number). This is semantically different from leaving them undefined. Defining them as NaN states that you want them to be NaN for modeling purposes, whereas undefined values leave it unclear what they could be. This change won't alter the mathematics of your model but please the validator.

Midnighter commented 2 years ago

Hi, I won't have time to look into this in the next two weeks. Since memote relies entirely on cobrapy to load models, please raise your issue there and I hope somebody will be able to help you find a solution.

carrascomj commented 2 years ago

I have run memote on your v2, which I had to modify a bit.

Memote report: index.html.txt

First, I have set the xmlns:fbc attribute to sbml 3.1 and fbc version 2. This way, the document is parsed using the FBC plugin. I am not sure if this is a cobrapy issue or a libsbml issue or if the FBC plugin is not compatible with sbml 3.2 (the sbml.org page is down, maybe someone knows more about this).

2,3c2,3
< <sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" sboTerm="SBO:0000624" version="2" xmlns:bqbiol="http://biomodels.net/biology-qualifiers/" xmlns:fbc="http://www.sbml.org/sbml/level3/version2/fbc/version2" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sbml="http://www.sbml.org/sbml/level3/version2/core" xmlns:xhtml="http://www.w3.org/1999/xhtml" fbc:required="false">
---
> <sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" sboTerm="SBO:0000624" version="2" xmlns:bqbiol="http://biomodels.net/biology-qualifiers/" xmlns:fbc="http://www.sbml.org/sbml/level3/version1/fbc/version2" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sbml="http://www.sbml.org/sbml/level3/version2/core" xmlns:xhtml="http://www.w3.org/1999/xhtml" fbc:required="false">

Second, you have to declare the parameters as constant. If not, they won't be linked to the reactions bounds and the parsing will fail. This is the behavior for fbc:strict = true. For fbc:strict = false (like you have), setting flux constraints to non-constant parameters is allowed from other sbml constructs (like AssignmentRule), but in this case your parameters are actually a numeric constant, so I guess rejecting the file may be correct (?).

37,40c37,40
<       <parameter id="cobra_default_lb"  units="mmol_per_gDW_per_hr" sboTerm="SBO:0000626" value="-1000" constant="false" />
<       <parameter id="cobra_default_ub" units="mmol_per_gDW_per_hr" sboTerm="SBO:0000626" value="1000" constant="false" />
<       <parameter id="cobra_0_bound" units="mmol_per_gDW_per_hr" sboTerm="SBO:0000626" value="0" constant="false" />
<       <parameter id="glc__D_bound" units="mmol_per_gDW_per_hr" sboTerm="SBO:0000626" value="-131" constant="false" />
---
>       <parameter id="cobra_default_lb"  units="mmol_per_gDW_per_hr" sboTerm="SBO:0000626" value="-1000" constant="true" />
>       <parameter id="cobra_default_ub" units="mmol_per_gDW_per_hr" sboTerm="SBO:0000626" value="1000" constant="true" />
>       <parameter id="cobra_0_bound" units="mmol_per_gDW_per_hr" sboTerm="SBO:0000626" value="0" constant="true" />
>       <parameter id="glc__D_bound" units="mmol_per_gDW_per_hr" sboTerm="SBO:0000626" value="-131" constant="true" />
draeger commented 2 years ago

The FBC package (no matter whether the package version is 1 or 2) is compatible with SBML Level 3 in both versions (1 and 2).

carrascomj commented 2 years ago

Then I think it is an issue with libsbml.

I have only grepped through the source code, but it seems like the declared namespaces do not include SBML level 3 version 2 (here).

draeger commented 2 years ago

Not sure if COBRApy supports SBML Level 3 Version 2. Definitely supports Version 1 of Level 3.

Wheaties91 commented 2 years ago

Thank you all for your help. Your suggestions, particularly those of carrascomj have worked!