adding package plugins

8 views
Skip to first unread message

Michiel Karrenbelt

unread,
May 11, 2019, 9:43:00 AM5/11/19
to libsbml-development

I would like to add a plugin to my model at a later stage than creation. Is there a way to do this?

what I tried so far: 

package = 'comp'
sbmlns
= self.doc.getSBMLNamespaces()
sbmlns
.addPackageNamespace(package, 1)
self.doc.setPackageRequired(package, True)

doesn't set it on the model. Creating a model will, but then you end up with an empty model

props = libsbml.ConversionProperties()
props
(sbmlns)
self.doc.convert(props)

-33: "Conversion with the given properties is not yet available."

Then I explored adding the package to the SBML namespace, directly on the document as well as on the model

self.doc.getSBMLNamespaces().addPackageNamespace('comp', 1)
self.doc.model.getSBMLNamespaces().addPackageNamespace('comp', 1)

-4: "A value passed as an argument to the method is not of a type that is valid for the operation or kind of object involved. For example, this return code is used when a calling program attempts to set an SBML object identifier to a string whose syntax does not conform to the SBML identifier syntax."

and although one can get the plugin from the model, the setPlugin method does not exists

self.doc.model.getPlugin('comp')

suggestions are welcome

Frank Bergmann

unread,
May 11, 2019, 4:03:55 PM5/11/19
to libsbml-d...@googlegroups.com
Hello,

all you need to do is to enable the package on the document and set
its required attribute:

```
doc.enablePackage(uri, "comp", True);
doc.setPackageRequired("comp", False);
```
where uri is the comp namespace that you can get from the comp
extension getXmlnsL3V1V1() function.

please let us know if you need more of a pointer.

best
Frank
> --
> You received this message because you are subscribed to the Google Groups "libsbml-development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to libsbml-develop...@googlegroups.com.
> To post to this group, send email to libsbml-d...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/libsbml-development/c106802e-bda0-4547-b14f-a6784376945e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Michiel Karrenbelt

unread,
May 12, 2019, 6:39:12 AM5/12/19
to libsbml-development
That was useful, thanks. Now I'm at the stage where I have two models and wish to add one as a submodel to the other.

comp = self.doc.getPlugin('comp')
comp_model
= self.doc.model.getPlugin('comp')

This doesn't work
comp_model.addSubmodel(new.doc.model)

So then the idea would be to create a submodel instead, but I don't know how to set the ModelRef
sub_model = comp_model.createSubmodel()
sub_model
.setId('new')
sub_model
.setModelRef(new.doc.model.id)

>> The value of a 'comp:modelRef' attribute on a <submodel> must be the identifier of a <model>, <modelDefinition>, or <externalModelDefinition> object in the same SBML object as the <submodel>

which seems a step in the right direction, but I also need to get the new model into the original model. The two lines below don't offer the solution though

comp.addModelDefinition(new.doc.model)
comp_model
.addSubmodel(new.doc.model)
comp_model
.addSubmodel(sub_model)

I played around a bit trying to create a model definition as well, but I don't think this is any different. I have the idea I'm still to properly port the models to be able to access its elements from the overarching model, but it seems I need to perform some sort of merging first. Since I'm trying to integrate relatively small and simple models, semanticSBML seems excessive; I rather achieve this without the use of another piece of software. 
> To unsubscribe from this group and stop receiving emails from it, send an email to libsbml-development+unsub...@googlegroups.com.

Frank T. Bergmann

unread,
May 13, 2019, 2:41:59 AM5/13/19
to libsbml-development
Hello, 

it is difficult to work out what precisely you would want to achieve.So perhaps you could let us know where you want to go with the hierarchical model and we could help out. For example, if you wanted to use a current (non-comp) model and create a new model out of it that instantiates it twice as submodels, then you would: 

1. create a new sbml document, with new model
2. load the exiting model
3. add the model loaded into the listofModelDefinitions of the doc from 1)
4. now in the model from 1) you would create the submodels, referencing the model of the model definition. 

best Frank


Reply all
Reply to author
Forward
0 new messages