Download Links

Simulate 3D | SBW (Win32) | Bifurcation Discovery | FluxBalance

Thursday, November 14, 2013

libSBML 5.9.0 Released

Its official the new libSBML 5.9.0 is available immediately from source forge:

There have been a number of changes. In the past months both the SBML Level 3 Qualitative Modeling Package, and the SBML Level 3 Layout Package have been released. From now on, they will be enabled and fully validated by every libSBML binary release.

And while there are many great new features (such as a converter that promotes all local reaction parameters to global ones, or a converter that attempts to infer units of elements), there are two new API introductions that I want to highlight below. Please see also the full release announcement.

ElementFilters: searching for elements

LibSBML 5.9.0 also introduces a new API, that makes it easier to search for specific elements in the SBML documents. You might be familiar with the SBase::getAllElements method, that until now would have returned all SBase elements below a certain element. So if you called it on a Event you would get a list containing of Trigger, Delay and EventAssignments. New is now, that getAllElements can optionally take an ElementFilter. In order to use the ElementFilter you would create a new class, that inherits from ElementFilter and implements one method:

virtual bool filter(const SBase* element);

This function can inspect an SBase element for its properties, and if it should be returned by getAllElements it would return true and false otherwise. This also works in the bindings languages, such as Python, Java or C#. So for example in C# if you would like a filter that filters for elements that contain Notes, you would implement the method like so:

public override bool filter(SBase element)
// return in case we don't have a valid element
// or the element contains no notes.
if (element == null || !element.isSetNotes())
return false;

// otherwise include it in the result
return true;

Then you simply pass that class into the call to getAllElements, and you would only receive elements with notes. Examples for this are in the examples folder of libSBML:

IdentifierTransformer: transforming elements

Another new concept included in 5.9.0 is the IdentifierTransformer class. This was initially motivated by the comp package, where often identifiers (SIds / METAIDs) would have to be renamed during flattening. Of course when you rename things, then you have to go through all references, to ensure that these would be corrected as well. To make this easier we included the IdentifierTransformer class. Similar as to the ElementFilter you would again inherit from that class and implement:

virtual int transform(SBase* element);

in order to use the transformer, you would first call getAllElements with the appropriate filter, to get a hold of all elements you would want to transform. and then go through them applying the transformer to the items. Of course this is useful even outside of comp. As example we include a transformer, that will updated all SBML Ids, to be as close as possible to their elements Name (by ensuring that all invalid characters such as spaces are removed from the name to represent a valid id):

Of course these transformers don't have to be used at all in the context of renaming identifiers. The general API also allows them to do pretty much any manipulations of the elements that you would like.

No comments: