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

Model notes are not written to SBML #902

Closed
Midnighter opened this issue Aug 21, 2019 · 7 comments
Closed

Model notes are not written to SBML #902

Midnighter opened this issue Aug 21, 2019 · 7 comments
Labels
SBML Related to reading and writing SBML models.

Comments

@Midnighter
Copy link
Member

Did we already have an issue for this?

import logging

logging.basicConfig(level="INFO")

import cobra
from cobra.io import write_sbml_model

cobra.show_versions()
System Information
==================
OS                     Linux
OS-release 4.15.0-58-generic
Python                 3.6.8

Package Versions
================
cobra                       0.16.0
depinfo                      1.5.1
future                      0.17.1
numpy                       1.17.0
optlang                      1.4.4
pandas                      0.25.0
pip                         19.2.1
python-libsbml-experimental 5.18.0
ruamel.yaml                 0.16.1
setuptools                  41.0.1
six                         1.12.0
swiglpk                     4.65.0
wheel                       0.33.4
model = cobra.Model()

model.notes["Remark"] = "This is not written to SBML."

met = cobra.Metabolite("pyr_c", compartment="c")

model.add_metabolites([met])

met.notes["Remark"] = "I appear."

rxn = cobra.Reaction("GOLD")

model.add_reactions([rxn])

rxn.notes["Remark"] = "What about me?"

write_sbml_model(model, "bug.xml")
@akaviaLab
Copy link
Contributor

Seems to be written on my development branch SBMLImprovments. Try testing after merging #901

@matthiaskoenig matthiaskoenig added the SBML Related to reading and writing SBML models. label Dec 20, 2019
@Hemant27031999
Copy link
Contributor

This issue is still unresolved. Notes attached with models are still not written to SBML. Can I work on this?

@akaviaLab
Copy link
Contributor

You're right. Reaction and metabolite notes are written, but model notes aren't.
The problem seems to be if hasattr(cobra_model, "_sbml"): in cobra.io.sbml._model_to_sbml

@matthiaskoenig Why does _sbase_notes_dict(sbase, notes) require the sbase to already exist?

As far as I'm concerned, you can work on it, but you might want to make sure you understand _sbase_notes_dict(sbase, notes).

@Hemant27031999
Copy link
Contributor

I think problem is not with "hasattr(cobra_model, "_sbml")". The _sbml attribute store the notes and annotation corresponding to the main SBML document. Annotation and Notes of models (present inside the SBML) are stored in cobra_model.annotation and cobra_model.notes respectively. In the method "_model_to_sbml()" where parsing is done, only annotation is parsed from cobra_model to libsbml.SBMLDocument (in line 938). Here we need to parse the notes also corresponding to that model. I added this and now it is working fine.

@akaviaLab
Copy link
Contributor

akaviaLab commented Mar 13, 2020 via email

@cdiener
Copy link
Member

cdiener commented Mar 13, 2020

Relevant prior discussions are here #695 (also see the schema link in there).

@Midnighter
Copy link
Member Author

Resolved by #943

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SBML Related to reading and writing SBML models.
Projects
None yet
Development

No branches or pull requests

5 participants