|
Hi Nicolas,
>> Hi all,
>>
>> here is a minimal example that doesn't work properly with the current
>> version of JSBML:
>>
>> public static void main(String[] args) throws Throwable {
>> SBMLDocument doc = new SBMLDocument(3, 1);
>> Model m = doc.createModel("m1");
>> Compartment c = m.createCompartment("c1");
>> Species s1 = m.createSpecies("s1", c);
>> Species s2 = m.createSpecies("s2", c);
>> Reaction r = m.createReaction("r1");
>> r.createReactant(s1).setStoichiometry(1d);
>> r.createProduct(s2).setStoichiometry(1d);
>> KineticLaw kl = r.createKineticLaw();
>> ASTNode one = new ASTNode(1, kl);
>> ASTNode two = new ASTNode(2, kl);
>> one.setUnits(Unit.Kind.MOLE.toString().toLowerCase());
>> two.setUnits(Unit.Kind.SECOND.toString().toLowerCase());
>> ASTNode ast = ASTNode.frac(one, two);
>> kl.setMath(ast);
>> SBMLWriter.write(doc, System.out, ' ', (short) 2);
>> }
>>
>> You'll see that the first unit is not written to SBML at all. The second
>> unit is written, but the namespace declaration is missing. I already
>> found what is probably the reason, but can't fix it at the moment: The
>> recursive check if the ASTNode contains unit declarations doesn't work.
> Not sure of what is going on there !!
>
> The unit of the first astnode is reset somewhere.
>
> if I print the value of the units in
> MathMLXMLStreamCompiler.compileInteger(ASTNode), the first astnode
> return 'null'.
>
> The sbml namespace is not added because the method
> FindUnitsCompiler.compile(int, String) is never called by the
> ASTNodeCompiler.
> Again, not sure why it would work sometimes and not others.
>
> Nico
>
>
Please have a look just at the implementation of the frac method within
the class org.sbml.jsbml.util.compilers.FindUnitsCompiler:
public ASTNodeValue frac(ASTNode numerator, ASTNode denominator)
throws SBMLException {
return dummyValue;
}
As you can see, the method does not perform any recursion. It simply
returns the dummyValue. If the numerator contains a number with a unit,
the FindUnitsCompiler won't be able to find it because the recursion
will already stop here. The same holds true for the denominator. No
chance to identify any number deeper inside of the fraction. Similarly,
all other methods in this class that are supposed to continue the
recursion by at least calling something like numerator.compile(this) and
denominator.compile(this) also do not perform any recursion. There are
many, many methods in this class that will have to be changed.
Cheers
Andreas
--
Dr. Andreas Dräger
University of Tuebingen
Center for Bioinformatics Tuebingen (ZBIT)
Sand 1
72076 Tübingen
Germany
Phone: +49-7071-29-78982
Fax: +49-7071-29-5091
____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development
For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/
For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu
|