Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mass balance not calculated, charge balance not calculated, annotations not detected #612

Closed
matthiaskoenig opened this issue Feb 13, 2019 · 7 comments

Comments

@matthiaskoenig
Copy link
Collaborator

Problem description

With the minimal example attached the model report gives very incorrect results. All species are annotated to chebi and kegg.compound; reactions are annotated to Uniprot. Everything has SBO terms. Nothing of this is detected in the report.
In addition mass and charge balance should exist for all reactions but are not reported.

Please explain:

  • what: tried to create model report
  • how memote report snapshot tiny_example_8.xml
  • why SBO terms are not detected on species and reactions, annotations are not detected on reactions and species, mass balance is not calculated, charge balance is not calculated

Code Sample

memote report snapshot tiny_example_8.xml

Model and results are attached
results.zip

Context

Please run the following code and paste the output inside the details
block.

import memote
memote.show_versions()

System Information

OS Linux
OS-release 4.15.0-45-generic
Python 3.5.2

Package Versions

Jinja2 2.10
click 6.7
click-configfile 0.2.3
click-log 0.3.2
cobra 0.14.2
cookiecutter 1.6.0
depinfo 1.5.0
equilibrator-api 0.1.26
future 0.17.1
gitpython 2.1.11
goodtables 1.0.0
importlib-resources 1.0.2
lxml 4.3.1
memote 0.9.3
numpydoc 0.8.0
pandas 0.23.4
pip 19.0.2
pygithub 1.43.5
pylru 1.1.0
pytest 4.2.1
python-libsbml 5.17.0
requests 2.21.0
ruamel.yaml 0.15.88
setuptools 40.8.0
six 1.12.0
sqlalchemy 1.2.17
sympy 1.3
travis-encrypt 1.1.2
travispy 0.3.5
wheel 0.33.0

@Midnighter
Copy link
Member

So there are a couple of things at play.

Annotation

This is an issue with cobrapy. Both metabolite and reaction annotations turn up empty. This is a problem with the parser.

In [13]: for rxn in model.reactions:
    ...:     print(rxn.id, rxn.annotation)
    ...: 
GK {}
ATPASE {}

In [14]: for met in model.metabolites:
    ...:     print(met.id, met.annotation)
    ...: 
glc {}
g6p {}
atp {}
adp {}

Balances

If you look at charges, the glucose charge of 0 is wrongly parsed as None.

In [15]: for met in model.metabolites:
    ...:     print(met.id, met.charge)
    ...: 
glc None
g6p -2
atp -4
adp -3

The metabolite formulae are parsed correctly but the reactions are actually mass unbalanced:

In [16]: for met, coef in model.reactions.ATPASE.metabolites.items():
    ...:     print(met.id, met.elements, coef)
    ...: 
atp {'C': 10, 'H': 12, 'N': 5, 'O': 13, 'P': 3} -1.0
adp {'C': 10, 'H': 12, 'N': 5, 'O': 10, 'P': 2} 1.0

In [17]: for met, coef in model.reactions.GK.metabolites.items():
    ...:     print(met.id, met.elements, coef)
    ...: 
glc {'C': 6, 'H': 12, 'O': 6} -1.0
atp {'C': 10, 'H': 12, 'N': 5, 'O': 13, 'P': 3} -1.0
g6p {'C': 6, 'H': 11, 'O': 9, 'P': 1} 1.0
adp {'C': 10, 'H': 12, 'N': 5, 'O': 10, 'P': 2} 1.0

Again this is a problem of the parser that wrongly parses the reactions. I think the problem here is that cobrapy is not yet compatible with SBML level 3 version 2.

@matthiaskoenig
Copy link
Collaborator Author

So it is my own issue somehow. We have to fix the SBML parser in cobrapy. This will most likely also fix this issue.
The reactions are mass balanced, the parser is just dropping metabolites from the reactions (I think constant metabolites). So SBML is mass balanced, the SBML parser in cobrapy is introducing the problems.
I you look at the SBML you can see

    <listOfReactants>
          <speciesReference species="glc" stoichiometry="1" constant="true"/>
          <speciesReference species="atp" stoichiometry="1" constant="true"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="g6p" stoichiometry="1" constant="true"/>
          <speciesReference species="adp" stoichiometry="1" constant="true"/>
          <speciesReference species="hydron" stoichiometry="1" constant="true"/>
        </listOfProducts>

Same for other reaction, where hydron, water and hydrogenphosphate are dropped from reaction equation.

@Midnighter
Copy link
Member

What tool are you using to generate the model? Directly via libsbml?

@matthiaskoenig
Copy link
Collaborator Author

matthiaskoenig commented Feb 14, 2019 via email

@Midnighter
Copy link
Member

Actually, that has always been the case yes. I didn't pay attention to that.

@Midnighter
Copy link
Member

I'll close this issue in favor of the one on cobrapy. Let's find a solution for this soon 😉

@matthiaskoenig
Copy link
Collaborator Author

Just for anybody running in the same issues. This is solved in
opencobra/cobrapy#685
Just use the libsbml branch of cobrapy with memote to make things work
https://github.com/opencobra/cobrapy/tree/libsbml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants