Enhancement of internal consistency checking
In libSBML through version 3, it's possible to create an internal representation of an SBML model that is invalid, yet will not cause
checkConsistency() to return errors. The underlying reason is that certain features are not checked by
checkConsistency(), but instead are assumed to have been checked at different points elsewhere in libSBML, or by the XML parser. Creating an in-memory model may not lead to those checks being performed. To help catch these additional cases, we have added an additional validation method.
Example of the issue
The following code is used to create an L1V2 model with one compartment:
SBMLDocument * doc = new SBMLDocument(); doc->setLevelAndVersion(1, 2); Model *m = doc->createModel(); Compartment *c = m->createCompartment();
Further code then sets the spatial dimensions of the compartment to 2 and then checks the consistency of the document.
c->setSpatialDimensions(2); int n = doc->checkConsistency();
The value of
n returned is "
0", i.e., no errors. This occurs because the document contains an L1V2 model and the attribute
spatialDimensions is not defined in the SBML L1V2 specification. As a result, consistency checks relating to
spatialDimensions will not be performed on compartment
LibSBML defines a new validator (internally called
InternalConsistencyValidator), which will run checks on the internal consistency of the model and report errors that are not detected by
A new method on the
unsigned int checkInternalConsistency();
InternalConsistencyValidator and performs the checks on the current document. Errors are logged in the
SBMLErrorLog object associated with the
SBMLdocument instance, and returns the number of errors. The
SBMLErrorLog can then be queried using existing methods.