If I try to convert a model with inconsistent units (attached), from level 4 to level 1, several things go wrong:
- 'SetLevelAndVersion(2,1)' returns false, and the text of the model is unchanged. I thought we had agreed that the converters were to go ahead and make the change, even if it produced invalid SBML, because it was then the job of the researcher/client program to fix the resulting model themselves?
-'CheckLeveL2v1Compatibility()' does *not* set the error 'SBML Level 2 Version 4 removed the requirement that all units be consistent...' error.
-The aforementioned 'all units be consistent' error is set to be severity 1 (Warning), even though libSBML refuses to translate the model as a result. Should be severity 2 (Error).
Here's the relevant code; it's app-specific, but it gives you the idea.
SBMLDocument* sbmldoc = readSBMLFromString(toPlainText().toUtf8());
bool success = sbmldoc->setLevelAndVersion(level, version);
if (success) {
ReplaceTextWith(writeSBMLToString(sbmldoc));
}
else {
//sbmldoc->getErrorLog()->clearLog();
//sbmldoc->checkL2v1Compatibility();
SBMLErrorLog* log = sbmldoc->getErrorLog();
string trueerrors = "";
for (unsigned int err=0; err<log->getNumErrors(); err++) {
const SBMLError* error = log->getError(err);
//if(error->getSeverity() >=2) {
if (trueerrors != "") trueerrors += "\n";
trueerrors += error->getMessage();
//}
}
QMessageBox msgBox;
QString message = "Error when attempting to translate '" + GetModelName() + "' to the selected level and version.";
msgBox.setText(message);
msgBox.setInformativeText(trueerrors.c_str());
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
ReplaceTextWith(writeSBMLToString(sbmldoc));
}
Updated libsbml version so this does not get lost
NOTICE NOTICE NOTICE
The comments associated with this ticket were lost in late 2014.
The SBML Team manually recovered the comments. The text is appended below.
NOTICE NOTICE NOTICE
Comment By: Sarah Keating (sarahkeating)
Date: 2013-08-05 11:52
Updated to 5.8.0
Hi Lucian
This item is rather old :-)
Is it something that still needs attention or did it get fixed with the strict flags regarding conversion ?
Thanks
Sarah
The conversion conventions are now fine, but problems remain. I'm including two different models with unit problems below; the original 'attached model' seems to have been lost:
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
<model id="__main" name="__main" volumeUnits="volume">
<listOfUnitDefinitions>
<unitDefinition id="second_litre">
<listOfUnits>
<unit kind="second" exponent="1" scale="0" multiplier="1"/>
<unit kind="litre" exponent="1" scale="0" multiplier="1"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="volume">
<listOfUnits>
<unit kind="litre" exponent="1" scale="0" multiplier="1"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>
<listOfCompartments>
<compartment sboTerm="SBO:0000410" id="default_compartment" spatialDimensions="3" size="1" constant="true"/>
</listOfCompartments>
<listOfSpecies>
<species id="a" compartment="default_compartment" initialConcentration="3" substanceUnits="second_litre" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
</listOfSpecies>
</model>
</sbml>
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
<model id="__main" name="__main">
<listOfParameters>
<parameter id="a" value="3" units="second" constant="true"/>
<parameter id="b" units="second" constant="false"/>
</listOfParameters>
<listOfRules>
<assignmentRule variable="b">
<apply>
<power/>
<ci> a </ci>
<cn type="integer"> 2 </cn>
</apply>
</assignmentRule>
</listOfRules>
</model>
</sbml>
This was addressed in the 5.13 release :-)
see https://www.pivotaltracker.com/story/show/111039268