Changing Model Names with Antimony or libSBML

17 views
Skip to first unread message

yosh...@uw.edu

unread,
Jul 13, 2018, 7:57:17 PM7/13/18
to sbml-interoperability
Hello,

I am currently trying to combine multiple small GRNs together using a combination of Antimony, Tellurium, and libSBML on python.

My desired workflow is this:
- Populate small motif model (in Antimony language) from a directory of text files. 
- Pick several motifs to attach together at a specific point, specified by user input. These selected motifs may even be the same motif multiple times.
- Combine them together to create a combined motif.

It is assumed that each motif has a specific 'p_input' and 'p_output' species that combines together when two motifs combine. 
Ex: 
Motif 1 (FFL): p_i -> p1 -| p_o, p_i -> p_o
Motif 2 (another FFL): p_i -| p1 -| p_o, p_i -> p_o

Combined motif (Motif 1 -> Motif 2): p_o in motif 1 and p_i in motif 2 are both set to be a new p_connect species.

Using the modules system from Antimony is ideal for this case, especially because there will be species and parameter naming conflicts between two modules (ie, motifs will have variables that have identical names). Antimony deals with this nicely by appending a naming scheme to variables in each module.

The one thing it cannot deal with that I have found a solution for so far are the actual Model names. When a user wants to *reuse* the same motif, then my current program will call the motif twice, but then gets confused when it sees two models with the same model name.

I saw .getName() and .setName() from libSBML but it seems to refer to IDs, not the actual model names. When I go from an Antimony model to SBML, then use .setName to change the model name, and then convert back to Antimony. Sort of hackish, but it works in theory for my use case. I expect the model name to change, but it did not.

Any suggestions here? The ideal solution would be to use a function in libSBML or even Antimony. Either one works because I have to convert the final Antimony model into SBML anyways to manually add some reactions in.

Lucian Smith

unread,
Jul 13, 2018, 8:03:53 PM7/13/18
to SBML Software Interoperability Discussion List
When you instantiate one model inside another (in both SBML and Antimony), that instantiation gets its own SId; the 'id' of the 'Submodel' object.  In Antimony syntax:

model foo()
  a =3
end

model bar()
  M1: foo()
  M2: foo()
end

Here, the model id is 'foo', but inside the model 'bar', it gets the id 'M1' the first time, and 'M2' the second time.

In SBML, the above model looks like:

<?xml version="1.0" encoding="UTF-8"?>

<sbml xmlns:comp="http://www.sbml.org/sbml/level3/version1/comp/version1" xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" version="2" comp:required="true">

<model id="bar" name="bar">

<comp:listOfSubmodels>

<comp:submodel comp:id="M1" comp:modelRef="foo"/>

<comp:submodel comp:id="M2" comp:modelRef="foo"/>

</comp:listOfSubmodels>

</model>

<comp:listOfModelDefinitions>

<comp:modelDefinition id="foo" name="foo">

<listOfParameters>

<parameter id="a" value="3" constant="true"/>

</listOfParameters>

</comp:modelDefinition>

</comp:listOfModelDefinitions>

</sbml>


Does that answer your question?  Glad to hear that Antimony and SBML-comp are working for you!

-Lucian

--
You received this message because you are subscribed to the Google Groups "sbml-interoperability" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sbml-interoperab...@googlegroups.com.
To post to this group, send email to sbml-inter...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sbml-interoperability/0faa6041-00a2-4289-a579-eee9e6ee3875%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sarah Keating

unread,
Jul 14, 2018, 6:03:18 AM7/14/18
to sbml-inter...@googlegroups.com

> I saw .getName() and .setName() from libSBML but it seems to refer to
> IDs, not the actual model names.


No, these functions work on the 'name' attribute not the 'id' :-)

Sarah

yosh...@uw.edu

unread,
Jul 17, 2018, 2:24:32 PM7/17/18
to sbml-interoperability
Hello Lucian,

Thanks for the super fast reply! Within 10 minutes! Wow. Unfortunately I couldn't reciprocate. Haha...

I figured out the problem. In summary, it's an issue with the fact that I'm calling up models from a directory without checking to see if two are identical. If they are, and they are both combined into one large antimony script before flattening, it won't work with the following commands I use to flatten the model. 
Going with your example, if I want to use model foo as a submodel twice in model bar, then my model bar script only needs one instance of model foo, or else flattening doesn't work. If I have model foo twice, because my script naively gobbles up and puts together two model files from a directory that have the same exact models, I run into flattening issues.

I currently use the following commands to flatten the original combined model. 
antimony.clearPreviousLoads()
antimony.loadAntimonyString(combined) <--- The issue happens here. It returns -1L when there is an error.
sbmlstr = antimony.getSBMLString('combined') <--- and smblstr is NoneType, screwing up everything afterwards.
antimony.loadSBMLString(sbmlstr)
flatcomb = antimony.getAntimonyString('combined')

-Yoshi
To unsubscribe from this group and stop receiving emails from it, send an email to sbml-interoperability+unsub...@googlegroups.com.

yosh...@uw.edu

unread,
Jul 17, 2018, 2:32:49 PM7/17/18
to sbml-interoperability
Hi Sarah,

You are totally right. Tellurium has a function te.sbmlToAntimony() that converts SBML models to Antimony models, but it seems like it uses the SBML ID attribute to populate the Antimony model name, instead of the SBML Name attribute.

-Yoshi
Reply all
Reply to author
Forward
0 new messages