Menu

#283 back-converting models with inconsistent units

libSBML-5.10.2
closed
nobody
2016-05-28
2009-10-13
No

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));

}

Discussion

  • Sarah Keating

    Sarah Keating - 2014-09-04
    • Version: libSBML-5.8.0 --> libSBML-5.10.2
     
  • Sarah Keating

    Sarah Keating - 2014-09-04

    Updated libsbml version so this does not get lost

     
  • Frank Bergmann

    Frank Bergmann - 2015-01-20

    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

     
  • Sarah Keating

    Sarah Keating - 2015-10-28

    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

     
  • Lucian Smith

    Lucian Smith - 2016-01-05

    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:

    • 'setLevelAndVersion' finds the problem and refuses to convert the document in both cases. However, in the first case, the error it reports references l2v1, though the model itself is still l3v1. Presumably, you want to put in error StrictUnitsRequiredInL2v1 (92008) instead. (It does ths for the second model).
    • 'checkL2v1compatibility' fails to notice anything wrong at all in both cases, and does not set any error. It should also set 'StrictUnitsRequiredInL2v1'. (The same is presumably true for checkL2v_ compatibility).
    • 'StrictUnitsRequiredInL2v1' (and other similar errors) should be an error, and not a warning, since conversion will fail if present.

    <?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>

     
  • Sarah Keating

    Sarah Keating - 2016-05-28

    This was addressed in the 5.13 release :-)

    see https://www.pivotaltracker.com/story/show/111039268

     
  • Sarah Keating

    Sarah Keating - 2016-05-28
    • status: open --> closed
     

Log in to post a comment.