simbiology duplicates sbml id tokens when "duplicate" is used

4 views (last 30 days)
Not sure if this is intended, but I believe that it does highlight a bug.
Say I create a model in simbiology, with species A and B. If I then copy and paste species A to get species A_1 I can use A_1, or rename it, and Simbiology works fine.
If however, I export the model to sbml using sbmlexport, species A and species A_1 have identical sbml IDs. This means that any model one creates and has used copy and pastes is basically unexportable, which kind of defeats the purpose of sbml. The duplicate IDs are used in rate expressions, so one has no way of knowing (from the sbml) which species is appropriate.
The best solution would be to create a new random id every time one copies a species, rule, parameter, .... or anything.
A signficant improvement would be to allow the user to specify that the IDs be identical to the names in sbmlexport, e.g.
sbmlexport(mc,'mysbml.xml',ids,'names');
A workaround right now would be to allow user access to the underlying ID that matlab assigns to a species (or a compartment or reaction. This would allow the user to change the duplicate IDs before export.
But right now, given a matlab model in an sbproj file, there is no guarantee that that file is exportable. Further, any sbml exported from simbiology/matlab cannot be trusted as useable for, for example, documenting models for publications.
If you have the sbproj file you could go through and create new compoartment, species, and parameter that is duplicated.
I've written some python scripts to find all duplicate ids and it may be easiest to use the list provided to manually edit the sbml file with duplicate ids.

Accepted Answer

Florian Augustin
Florian Augustin on 15 Jul 2022
Hi Jim,
Thank you for reporting this bug. A fix is included in R2022a Update 3. The releases R2021b Update 4, R2021a Update 7, R2020b Update 8 will also include this fix.
This update, however, does not disambiguate duplicate IDs in already existing models. We are currently looking for solultions to resolve this issue.
Best regards,
Florian

More Answers (1)

Jim Bosley
Jim Bosley on 15 Jul 2022
Florian, Thanks!
To remind folks of the use case here, if one creates a model in Simbiology and uses copy/paste on the graphical objects in the model, Simbiology creates a new element (say, a species) with a new NAME. For example, glucose -> glucose_1. Simbiology unfortunately used to (fixedin 2022av3, I think) copy the species ID without changing it. So two species (or compartments, or parameters- whatever you copied and pasted) would have two identical IDs. Not a problem within Simbiology/matlab, as they uses the NAME for equations. But sbmlexport writes the equations using the IDs. And if the IDs are duplicates, the model is wrong. I wanted a fix.
Let me share here the short-term fix that Florian supplied that solved my problem. If you have the sbproj file and want an sbml file, this works:
simbiology('original_model.sbproj'); %This is the file with duplicate ID tags:
% Works in Simbiology/Mathworks (they use variable NAMEs)
% Won't export to sbml correctly: sbmlexport uses IDs
% the model is now loaded into the SB root object
sbr=sbioroot;
mc = sbr.Models(end); % original model has duplicate IDs
mn = copyobj(mc); % copied model has new, unique IDs
sbmlexport(mn,'new_model.sbml') % Export new model with unique IDs!
You pointed out that if you do something like
sbiosaveproject 'new_model.sbproj' mn
the new file does not have the same graphical layout - you have to reprettyfy the diagram. Also, if your target software is rigorous, any rate equation that has species other than the reactants or products will need to have those added as a modifier. Last, any simbiology tasks (sims, fittings, etc) you have associated with the original mc model aren't saved.
But the fact is, if you have an sbproj file you can save it as an sbml with non-duplicated IDs.
Unfortunately, if you have only the sbml, the mapping is not "one-to-one and onto" and hence can't be easlly reversed engineered. One would need to manually curate such a file to recreate the original model.

Categories

Find more on Scan Parameter Ranges in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!