cobrapy icon indicating copy to clipboard operation
cobrapy copied to clipboard

ModelSEED SBML model can't be read due to duplicated IDs

Open dengxiao01 opened this issue 3 years ago • 12 comments

Problem description

image image

Code Sample

Create a minimal, complete, verifiable example.

Context

dengxiao01 avatar Jun 17 '22 07:06 dengxiao01

What is the result of the SBML validation? I am pretty sure your SBML is invalid and you should fix the issues in your model file.

matthiaskoenig avatar Jun 17 '22 09:06 matthiaskoenig

What is the result of the SBML validation? I am pretty sure your SBML is invalid and you should fix the issues in your model file.

SBML validation of web site, http://sbml.org/validator, is invalid, 404, is there where you can verify?

dengxiao01 avatar Jun 20 '22 02:06 dengxiao01

Sorry, link changed with the site migration. https://sbml.org/validator_servlet/ Best Matthias

matthiaskoenig avatar Jun 20 '22 07:06 matthiaskoenig

Fixed in https://github.com/opencobra/cobrapy/pull/1239

matthiaskoenig avatar Jun 20 '22 07:06 matthiaskoenig

Any chance that you can add a redirect on the proxy that runs sbml.org?

Midnighter avatar Jun 20 '22 17:06 Midnighter

Sorry, link changed with the site migration. https://sbml.org/validator_servlet/ Best Matthias thanks,this is the result of the SBML validation: This document is not valid SBML! Error Line 1181 Column 54: (SBML Validation Rule #10301) The value of the 'id' field on every instance of the following type of object in a model must be unique: , <functionDefinition>, <compartmentType>, , <speciesType>, , , <speciesReference>, <modifierSpeciesReference>, , and model-wide s. Note that <unitDefinition> and parameters defined inside a reaction are treated separately. Reference: L2V1 Section 3.5 The id 'M_cpd02701_b' conflicts with the previously defined id 'M_cpd02701_b' at line 674. <species id="M_cpd02701_b" name="S_Adenosyl_4_methylthio_2_oxobutanoate_c0_b" compartment="c0" charge="0" boundaryCondition="true"/>

image

dengxiao01 avatar Jun 21 '22 01:06 dengxiao01

Any chance that you can add a redirect on the proxy that runs sbml.org?

Thank you. How do I do that? I'm not adding weighted direction

dengxiao01 avatar Jun 21 '22 02:06 dengxiao01

Any chance that you can add a redirect on the proxy that runs sbml.org?

Thank you. How do I do that? I'm not adding weighted direction

Sorry, that was a comment for @matthiaskoenig

Midnighter avatar Jun 21 '22 07:06 Midnighter

Here is a MRE:

  1. Go to https://modelseed.org/genomes/Plants and download the A. Thaliana (2nd in the list) SBML model.
  2. Read the model with cobra.io.read_sbml_model

This will result in:

[...]
ValueError: id 'cpd02701_b' at index 1154 is non-unique. Is it present twice?

The above exception was the direct cause of the following exception:

CobraSBMLError                            Traceback (most recent call last)
Input In [8], in <cell line: 1>()
----> 1 mod = read_sbml_model("Athaliana-TAIR10.sbml")

File ~/code/cobrapy/src/cobra/io/sbml.py:472, in read_sbml_model(filename, number, f_replace, **kwargs)
    462 except Exception as original_error:
    463     cobra_error = CobraSBMLError(
    464         "Something went wrong reading the SBML model. Most likely the SBML"
    465         " model is not valid. Please check that your model is valid using "
   (...)
    470         "at https://github.com/opencobra/cobrapy/issues ."
    471     )
--> 472     raise cobra_error from original_error

CobraSBMLError: 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 .

Which points towards the same issue as the SBML validator. The issue is that ModelSEED provided invalid SBML models (duplicated IDs). @Midnighter Do you know where we should report this issue and what ModelSEED uses to generate the SBML model?

cdiener avatar Jun 21 '22 17:06 cdiener

@Midnighter I just opened the issue for the redirect. This should be fixed soon. See https://github.com/sbmlteam/sbml-org-website/issues/39

matthiaskoenig avatar Jun 21 '22 19:06 matthiaskoenig

I tried to read it without error using libsbml: reader = libsbml.SBMLReader() document = reader.readSBML(sbml_test_file) print(document.getNumErrors()) print(document.printErrors()) but the ModelSEED provided invalid SBML models (duplicated IDs),How does cobrapy solve this problem?

dengxiao01 avatar Jun 22 '22 06:06 dengxiao01

Reading the document with libsbml does not perform validation. You have to run the validation before you will see the actual errors. LibSBML will provide exactly the same errors (i.e. you model is invalid because you have duplicate species in it), because cobrapy and the sbml.org validator are using libsbml. In summary, your model is invalid and you have to fix the model. This is not related to cobrapy but to ModelSEED creating/distributing invalid/broken models. You have to fix your duplicate species. This can be complicated, because both will most likely appear in reactions and you have to resolve which of the species belongs actual to which reaction. In summary: this is not an issue of cobrapy, but of your model.

matthiaskoenig avatar Jun 22 '22 07:06 matthiaskoenig

Closing in favor of the attached ModelSEED issue where that issue originates.

cdiener avatar Jun 22 '23 21:06 cdiener