-
Notifications
You must be signed in to change notification settings - Fork 217
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
SBML write returns error when values are integers #724
Comments
Hi thanks for the report. Even though it does not say that anywhere in the docs model annotations currently have to be compliant with http://identifiers.org/. So annotations can currently not be anything different from strings. There is an ongoing discussion on how to implement evidence annotations and it is definitely on the radar. |
@matthiaskoenig is re-working the SBML parser/writer at the moment. I don't think a simple integer will work because the SBML specification requires annotations to be proper XML elements with namespace URI (cf. pp. 15 of the SBML spec PDF http://sbml.org/Documents/Specifications). For reference you can also take a look at discussions in: |
First of all thanks for replying so quickly. @Midnighter do you mean that I should add my annotations (to compounds and reactions) in the form like |
Short answer: Not at the moment. As @cdiener said and as you can see in your above error trace we expect all annotations (except SBO) to resolve to identifiers.org: "http://identifiers.org/%s/%s" % (provider, identifier) where 'provider' and 'identifier' are key and value(s) from the 'annotation' dictionary. However, the SBML spec says that tools should leave annotations that they don't use/can't read alone so it might be an idea to create a separate annotation attribute that contains pure XML. You could then add your own arbitrary XML there. What do you think @matthiaskoenig? |
@Midnighter I thought in the same direction. Because how things are currently handled all annotations which are not RDF triplets to ontologies are lost during the round trip read - write SBML. I will finish the libsbml issues during the next few days and will have a look at this issue. But yes, everything which is not annotations must be valid XML. |
This will be solved as part of #684. |
Problem description
Hi, while saving a model by using
cobra.io.write_sbml_model
the system returns the error reported below.Actual Output
TypeError Traceback (most recent call last)
in ()
----> 1 cobra.io.write_sbml_model(myWT5260_NCBI_v1, "Streptomyces-rimosus-WT5260/models/GBM_WT5260_ver1.0.sbml")
2 myWT5260_NCBI_v2 = deepcopy(myWT5260_NCBI_v1)
3 myWT5260_NCBI_v2.model_summary()
~/Documents/git-projects/genome-based-models/env_gbm/lib/python3.6/site-packages/cobra/io/sbml3.py in write_sbml_model(cobra_model, filename, use_fbc_package, **kwargs)
715 return
716 # create xml
--> 717 xml = model_to_xml(cobra_model, **kwargs)
718 write_args = {"encoding": "UTF-8", "xml_declaration": True}
719 if _with_lxml:
~/Documents/git-projects/genome-based-models/env_gbm/lib/python3.6/site-packages/cobra/io/sbml3.py in model_to_xml(cobra_model, units)
512 reversible=str(reaction.lower_bound < 0).lower())
513 set_attrib(sbml_reaction, "name", reaction.name)
--> 514 annotate_sbml_from_cobra(sbml_reaction, reaction)
515 # add in bounds
516 set_attrib(sbml_reaction, "fbc:upperFluxBound",
~/Documents/git-projects/genome-based-models/env_gbm/lib/python3.6/site-packages/cobra/io/sbml3.py in annotate_sbml_from_cobra(sbml_element, cobra_element)
248 if isinstance(identifiers, string_types):
249 identifiers = (identifiers,)
--> 250 for identifier in identifiers:
251 li = SubElement(bag, ns("rdf:li"))
252 set_attrib(li, "rdf:resource", "http://identifiers.org/%s/%s" %
TypeError: 'int' object is not iterable
Expected Output
Save goes successfully
Dependency Information
Please paste the output of
python -c "from cobra import show_versions; show_versions()"
in the details block below.System Information
OS Darwin
OS-release 17.5.0
Python 3.6.2
Package Versions
cobra 0.13.0
depinfo 1.3.0
future 0.16.0
numpy 1.14.3
optlang 1.4.2
pandas 0.23.0
pip 9.0.3
ruamel.yaml 0.14.12
setuptools 39.0.1
six 1.11.0
swiglpk 1.4.4
tabulate 0.8.2
The text was updated successfully, but these errors were encountered: