SourceForge has been redesigned. Learn more.

#32 SBMLDocument.getNumErrors() return 0 even when having errors

jsbml 1.0

A huge problem with the current jsbml version.
The getNumErrors() function of the SBMLDocument class always retrun 0...
So it is impossible to test if a readed SBML model has errors or no..

It can be tested with the following really simple function:

File f = new File("model.xml");
SBMLReader reader = new SBMLReader();
SBMLDocument doc = reader.readSBML(f);
catch (Exception e){e.printStackTrace();}

if you need an SBML file with errors to test, you can download this one:

Also, another remark concerning the behavior of jsbml concerning parsing errors.
Currently, if a model, a reaction or a species as an incorrect identifier like for example "M_PIn-1_c" (that contains a dash):
the library return the error:

ERROR ( - "M_PIn-1_c" is not a valid identifier for this species.

but unfortunately, the corresponding species would be created with an empty ID, which pose many problems. It would be preferable to create the species with its original ID (or its original ID with all non allowed characters removed or replaced by a "_") so that we could still be able to manipulate and export the model (with a warning saying that the ID does not fulfill SBML requirements, if we have keep it as it is) if we want to.
This is a really problematic issue as many published models does actually not respect the SBML specifications so it is impossible to read them correctly with JSBML (many objects have resulting empty IDs and it is impossible to trace back who is who...)


  • Nicolas Rodriguez

    Sorry it took us so long to answer.

    When you call "SBMLDocument doc = reader.readSBML(f);" indeed there will be no errors in the SBMLDocument error log. That's a behaviour that is different from libsbml where some problems could be reported directly after reading a model. Errors in JSBML will be reported at the moment through the Error and Warning messages and if anything too serious is detected, an Exception would be raised and you would not be able to read the model.

    To get the actual consistency check errors, you need to call a method on the SBMLDocument, then if your document is invalid and contain Errors, calling doc.getNumErrors() will return something different from zero.

    The exact command is :


    This is using directly the online validator at the moment as we did not wanted to re-implement the full model validation twice.

    For the second part of your tracker item, we know that JSBML is not really good to open invalid models. It was design more with the idea that you create your SBML file through an editor and that you should prevent anything invalid to be set as soon as possible. But in your example, it is obviously a problem that prevent you to use JSBML to manipulate this particular model and you would need to use a text editor or scripts to fix the model before it can be used with JSBML which is not really nice.
    We already planned and agreed to changes things to be more flexible when reading a model and some checks could be relaxed at the time you are reading the model. But it will take time to implement that and I am not sure it will be possible to include it on the next JSBML release with the current resources and time we have.

  • Nicolas Rodriguez

    • labels: 1231700 -->
    • status: open --> open-later
  • Nicolas Rodriguez

    • Description has changed:


    --- old
    +++ new
    @@ -1,4 +1,3 @@
     A huge problem with the current jsbml version.
     The getNumErrors\(\) function of the SBMLDocument class always retrun 0...
     So it is impossible to test if a readed SBML model has errors or no..
    • status: open-later --> closed-fixed
    • assigned_to: Nicolas Rodriguez
    • Group: --> jsbml 1.0
  • Nicolas Rodriguez

    With the start of the implementation of a pure JSBML validator, we did relax many checks when reading a model so that we are able to read the model as it is to do a proper and complete validation.
    So the reported problem with empty id when there are duplicated id won't happen any more.