#9 GSoC’18 – Support for the comp package

SBML level 3 supports several packages for added modeling functionality. Some examples are arrays, hierarchical model composition (comp), flux balance constraints etc. A detailed list of all the available packages, along with their mailing lists and discussion forum, for SBML level 3 can be found here.

This week’s work mainly focused on adding support for hierarchical model composition package. The official description of comp package is as follows:

A means for defining how a model is composed from other models

The comp package is a powerful tool for model representation. It allows the nesting of submodels within a model. The complete specification of all the SBML elements can be found in their latest specification.

How to deal with hierarchical SBML models?

As per SBML experts, the simplest way to deal with submodels is to flatten them. A complete description of the flattening strategy can be found here. In my case, I don’t need to flatten the models myself since it has already been implemented by Christoph Blessing as part of the jSBML library. My goal, instead, is the reverse mapping i.e. mapping flattened submodels back to their original model id.

How to map submodels to original id?

jSBML library can parse SBML files. After it reads an SBML file, a tree-like object is constructed which can be recursively parsed to find a child element. Originally, I wrote a very clumsy code however after some guidance from my mentor Andreas, we have a short class AddMetaInfo.java with static methods which is called before a model is flattened. It adds some meta information about submodel id’s in a HashMap which can later be retrieved in an efficient fashion.

A simple example to do it will be as follows: Read an SBML file which contains submodels and store meta-information about original id’s.

// Read original SBML file and add meta-info about original ID
SBMLDocument origDoc = SBMLReader.read(file);
origDoc = AddMetaInfo.putOrigId(origDoc);

Flatten the model and solve individual models using one of the solvers available in SBSCL.

// Flatten the model extra information in userObjects
 CompFlatteningConverter compFlatteningConverter = new CompFlatteningConverter();
 SBMLDocument flatDoc = compFlatteningConverter.flatten(origDoc);

/* call SBSCL's solvers for solving flattened models */

After running solvers simply map submodels to original ids.

// Map the output ids back to the original model

AbstractTreeNode node = (AbstractTreeNode) origDoc.getElementBySId(solution.getColumnIdentifier(index));

if(node.isSetUserObjects()) {
System.out.println("flat id: " + solution.getColumnIdentifier(index) + "\t old id:" + node.getUserObject(AddMetaInfo.ORIG_ID) + "\t model enclosing it: " +  node.getUserObject(AddMetaInfo.MODEL_ID));

That’s all folks. The full example can be found on GitHub.

Let me know if any issues or questions.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s