Simple assignments are not converted to correct formulas

10 views
Skip to first unread message

Matthias König

unread,
Oct 3, 2017, 11:40:10 AM10/3/17
to jsbml-development
Hi all,

Somehow when converting eventAssignments to strings via

eventAssignment.getMath().toFormula()

incorrect formulas are generated in the case of simple assignments like (p = 0).
This is a problem of the toString methods somehow.

Example attached, when calling

eventAssignment.getMath().toFormula()

on

<eventAssignment metaid="_324053" variable="kf_13">
            <math xmlns="http://www.w3.org/1998/Math/MathML">
              <cn>0</cn>
            </math>
</eventAssignment>

I expect:
kf_13 = 0
but the output is:
parameter [ id="kf_13" metaid="metaid_0000063" constant="false" sboTerm="SBO:0000035" value="1500"] = 0

with version
<dependency>
<groupId>org.sbml.jsbml</groupId>
<artifactId>jsbml</artifactId>
<version>1.3-SNAPSHOT</version>
</dependency>

Also in assignment rules and probably in all simple assignment math.
See also
https://github.com/matthiaskoenig/cy3sbml/issues/227


Best Matthias

cy3sbml644178491917996742.xml

Nicolas Rodriguez

unread,
Oct 4, 2017, 9:55:01 AM10/4/17
to jsbml-de...@googlegroups.com

Hi Matthias,



On 03/10/17 16:40, 'Matthias König' via jsbml-development wrote:
Hi all,

Somehow when converting eventAssignments to strings via

eventAssignment.getMath().toFormula()

incorrect formulas are generated in the case of simple assignments like (p = 0).
This is a problem of the toString methods somehow.

Example attached, when calling

eventAssignment.getMath().toFormula()

on

<eventAssignment metaid="_324053" variable="kf_13">
            <math xmlns="http://www.w3.org/1998/Math/MathML">
              <cn>0</cn>
            </math>
</eventAssignment>

I expect:
kf_13 = 0
but the output is:
parameter [ id="kf_13" metaid="metaid_0000063" constant="false" sboTerm="SBO:0000035" value="1500"] = 0


There has been a general move to change the toString methods in JSBML to print only very simple things about the class and class attributes.


For classes where we thought that users might like to keep the way the toString worked before, we created some printXXX methods so that they can

be sure to get the same result as previously (like AStNode.printASTNode to get the formula). The changes to ASTNode.toString() had many side effects so we reverted

that quickly. I would have thought that the maven snapshot did not contain this change but may be something went wrong somewhere.


Anyway, I have made a change to eventAssignment.toFormula() and it should now return what you expect. Note that I am not calling toFormulat() on the ASTNode as otherwise it will not display 'kf_13 = ', only what is on the mathML.

For other Assignment type classes, like InitialAssignment or AssignmentRule, there is not a method
toFormula() like in EventAssignment but we could add it if you think it would be good ?

I have updated the 1.3-snapshot so could you try again to see if you problem is resolved ?

Thanks,
Nico

Matthias König

unread,
Oct 4, 2017, 12:00:38 PM10/4/17
to jsbml-development

Hi Nicolas,
Just tried the latest commit, but is not fixed
I think the problem is in the

math.toFormula()

not on the eventAssignment.toFormula method (I did not even know this exists)

The math.toFormula() method generates incorrect formulas for the simple math, i.e.

parameter [ id="kf_13" metaid="metaid_0000063" constant="false" sboTerm="SBO:0000035" value="1500"] = 0


The math.toFormula() method must generate a string which one could later consume again with the formula parse methods like
parseFormulaWithModel()

Sorry, I was not exact enough. I am seeing the same issue on all such simple math.toFormula() calls, i.e. in math from EventAssignements, InitialAssignments or AssignmentRules.

M

niko.rodrigue

unread,
Oct 4, 2017, 12:10:59 PM10/4/17
to jsbml-development
Hi Matthias,

There is probably a problem in maven, either in the way I deploy it or the configuration you are using. On the ASTNode.toFormula() on master, there is for sure no way it could print ''variable = formula', it should be only the formula.

I will try it at home, using maven on a fresh project. Would it be easy for you to try on a github clone, using the jar produced from 'ant bigjar'.

Matthias König

unread,
Oct 4, 2017, 1:00:56 PM10/4/17
to jsbml-development
Hi Nico,
thanks for the help and input. Brought me on the right track.
The problem was on my side. Everything works now.

M
Reply all
Reply to author
Forward
0 new messages