sbmlteam / jsbml

JSBML is a community-driven project to create a free, open-source, pure Java™ library for reading, writing, and manipulating SBML files (the Systems Biology Markup Language) and data streams. It is an alternative to the mixed Java/native code-based interface provided in libSBML.
https://sbml.org/software/jsbml/
GNU Lesser General Public License v2.1
37 stars 24 forks source link

The test if a plugin is loaded returns true when JSBML has a parser loaded #216

Open draeger opened 4 years ago

draeger commented 4 years ago

The test isSetPlugin on AbstractSBase should return true if the SBase has a child with the given namespace. In the current implementation, however, it returns true if JSBML has (at some point) loaded a parser for parsing that namespace.

For example, if a model has an FBC extension in package version 1, JSBML will return true when asking model.isSetPlugin with the namespace of FBC package version 2 as argument. For testing, the model 01190 from the SBML test suite can be used.

The desired behavior of this method (and the corresponding method hasExtension) is that it should only return true if an extension with the given namespace exists.

hemilpanchiwala commented 4 years ago

Along with this issue, while running the statements model.getPlugin(fbcNamespaceV1) == null and model.getPlugin(fbcNamespaceV2) == null for the model 01190 from the SBML test suite both returns false value. However, the case should be that one of them should return true value.

niko-rodrigue commented 4 years ago

I can see that it can be confusing. We need at least to make the documentation clearer. My thinking on allowing namespace as well was to make it more convenient for people but make it work like when you use the package label, meaning returning the plugin if it does exist. Also, if we make the method strict, it will force people to update their code when a new version of the package is out, even if the code would have work properly without change.

I don't think this method is use too much with namespace so we could change it's behaviour.

I see two options:

What do you think ?

niko-rodrigue commented 4 years ago

Also if you are really writing a piece of code for only a specific version of a package, you might just test it at the SBMLDocument level and stop right without doing anything else if it is not the right one.

draeger commented 4 years ago

@niko-rodrigue which convenient method in JSBML can be used to answer the question if an arbitrary instance of an SBase has any extension package (of a specific short label or namespace) attached?

niko-rodrigue commented 4 years ago

@niko-rodrigue which convenient method in JSBML can be used to answer the question if an arbitrary instance of an SBase has any extension package (of a specific short label or namespace) attached?

Not really related to the issue but you have: https://sbmlteam.github.io/jsbml/files/doc/api/1.5/org/sbml/jsbml/SBase.html#getNumPlugins--

as well as SBase#getExtensionCount()

Or if I misunderstood your question, SBase#isSetPlugin

draeger commented 4 years ago

Ok, but these methods won't answer the question if a specific extension, such as fbc, is attached to an instance of SBase. So, we can check if there is any extension but then don't know which one, nor if the one of interest is there.