FYI, I have rewritten the convertSBMLToCobra function,
while retaining backwards compatibility with the legacyFlag option
(which I have also added to the readCbModel function). This rewrite
incorporates the newly vectorized functions parseSBMLAnnotation,
parseSBMLNotesField, and parseBoolean. I've also added quite a bit of commenting in the code, and reformatted it for readability.
A primary goal in this rewrite was to keep backwards compatibility, so I didn't add any new fields or parse annotation differently than the COBRA currently does. However, I want to facilitate future standards-compliant annotation, so expect to keep working on that going forward.
This update rearranges the COBRA model structure by grouping metabolite and reaction information, and adds the following fields: metCompartment, unparsedMetAnnotations, rxnNotes, compartments, compartmentNames
This rewrite is an incremental step away from the legacy approach of
parsing metabolite and reaction names for information that is now
encoded in other fields in SBML. My intent is to be able to read old models, but in the future, improve the COBRA Toolbox support for writing models with updated SBML versions and levels (ie, move annotation from notes fields to annotation fields, and hopefully offload lots of annotation parsing from the COBRA Toolbox to the SBML Toolbox). As you know, this process of standards evolution is slow, and involves lots of conversation with SBML folks, so there's no immediate changes to SBML writing functionality.
Unlike the older code, this new code successfully imports the following fields from notes and annotations:
metCharge, metChEBIID, metKEGGID, rxnConfidenceScores
I have tested that this code works with the following models: iND750, iAF1260, recon2, and Yeast 6.
This code also modularizes the parsing of notes and annotations in a way that should facilitate future support for the SBML fbc and annotation packages.