opencobra / cobrapy

COBRApy is a package for constraint-based modeling of metabolic networks.
http://opencobra.github.io/cobrapy/
GNU General Public License v2.0
460 stars 216 forks source link

cobra.io.sbml.validate_sbml_model Human-GEM.xml #1136

Closed helenaherand closed 2 years ago

helenaherand commented 2 years ago

Human-GEM.xml= "<?xml version="1.0" encoding="UTF-8"?>

Genome-scale metabolic models are valuable tools to study metabolism and provide a scaffold for the integrative analysis of omics data. This is the latest version of Human-GEM, which is a genome-scale metabolic model of a generic human cell. The objective of Human-GEM is to serve as a community model for enabling integrative and mechanistic studies of human metabolism.

...
" #This is the model I am trying to open https://github.com/SysBioChalmers/Human-GEM/blob/main/model/Human-GEM.xml Path="Human-GEM.xml" cobra.io.sbml.validate_sbml_model(Path) (None, {'SBML_FATAL': [], 'SBML_ERROR': ['E0 (Error): XML content (core, L116254); Badly formed XML; XML content is not well-formed.\n', 'E1 (Error): General SBML conformance (core, L3); No model definition found; An SBML document must contain a element. The element is optional in L3V2 and beyond.\nReference: L3V1 Section 4.1\n'], 'SBML_SCHEMA_ERROR': [], 'SBML_WARNING': [], 'COBRA_FATAL': [], 'COBRA_ERROR': ['No SBML model detected in file.'], 'COBRA_WARNING': [], 'COBRA_CHECK': []}) I am trying to read Human-GEM.xml with cobra.io.read_sbml_model(Human-GEM.xml) but CobraSBMLError: No SBML model detected in file. Why is Human-GEM.xml not a valid SBML model?
cdiener commented 2 years ago

I think you might have downloaded the GitHub preview page. Can you try downloading using the "Download" button on the upper right?

helenaherand commented 2 years ago

Hi Christian, Thanks for your comment. I did not download the GitHub preview page. I downloaded the file with wget and "Download Linked File As"

helenaherand commented 2 years ago

If I download the model using "Download Linked File" and remove the .txt extension (and use the .xml extension) I get:

(None, {'SBML_FATAL': [], 'SBML_ERROR': [], 'SBML_SCHEMA_ERROR': [], 'SBML_WARNING': ['E0 (Warning): General SBML conformance (core, L3); RDF does not contain valid ModelHistory; LibSBML expected to read the annotation into a ModelHistory object. Unfortunately, some attributes were not present or correct and the resulting ModelHistory object will not correctly produce the annotation. This functionality will be improved in later versions of libSBML. \nReference: L3V1 Section 6.3\n An invalid ModelHistory element has been stored.\n', 'E1 (Warning): General SBML conformance (core, L3); RDF does not contain valid ModelHistory; LibSBML expected to read the annotation into a ModelHistory object. Unfortunately, some attributes were not present or correct and the resulting ModelHistory object will not correctly produce the annotation. This functionality will be improved in later versions of libSBML. \nReference: L3V1 Section 6.3\n An invalid ModelHistory element has been stored.\n'], 'COBRA_FATAL': ['None is not a valid solver interface. Pick one from scipy.'], 'COBRA_ERROR': [], 'COBRA_WARNING': [], 'COBRA_CHECK': []})

cdiener commented 2 years ago

Hm, looks like your optlang installation is broken. You could try to reinstall with pip install optlang and post the errors here.

helenaherand commented 2 years ago

Yes. I did. SolverNotFound: None is not a valid solver interface. Pick one from scipy.

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

CobraSBMLError Traceback (most recent call last)

in 3 from os.path import join 4 data_dir = '' ----> 5 model = cobra.io.read_sbml_model(join(data_dir, 'Human-GEM.xml')) ~/opt/anaconda3/envs/my-rdkit-env/lib/python3.7/site-packages/cobra/io/sbml.py in read_sbml_model(filename, number, f_replace, **kwargs) 262 "at https://github.com/opencobra/cobrapy/issues ." 263 ) --> 264 raise cobra_error from original_error 265 266 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 .
helenaherand commented 2 years ago

I uninstalled optlang and reinstalled it with pip3 install --target=d:/Users/helher/opt/anaconda3/envs/my-rdkit-env/lib/python3.7/site-packages optlang (because of #1137). I tried to open the model elsewhere and it worked so something is not properly configured in my laptop. I will try to find a solution and closing this issue. Thanks, Christian.