Forums

F.A.Q. F.A.Q.    Register Register    Login Login    Home Home
Search Search
SBML Discussions » jsbml-development » Bug in SBMLWriter
Show: Today's Posts  :: Message Navigator
| Subscribe to topic 
Return to the default flat view Create a new topic Submit Reply
AuthorTopic
Andreas Dräger


Posts: 273
Registered:
June 2006
Re: Bug in SBMLWriter 10 May '12 04:59 Go to previous message

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

      

SubjectPosterDate
Read Message   Bug in SBMLWriter Andreas Dräger08 May '12 05:57
Read Message   Re: Bug in SBMLWriter rodrigue08 May '12 06:17
Read Message   Re: Bug in SBMLWriter Andreas Dräger08 May '12 06:20
Read Message   Re: Bug in SBMLWriter rodrigue08 May '12 06:30
Read Message   Re: Bug in SBMLWriter rodrigue08 May '12 06:43
Read Message   Re: Bug in SBMLWriter rodrigue08 May '12 07:10
Read Message   Re: Bug in SBMLWriter Andreas Dräger09 May '12 11:42
Read Message   Re: Bug in SBMLWriter rodrigue10 May '12 04:49
Read Message   Re: Bug in SBMLWriter rodrigue10 May '12 04:57
Read Message   Re: Bug in SBMLWriter rodrigue10 May '12 05:38
Read Message   Re: Bug in SBMLWriter Andreas Dräger10 May '12 05:50
Read Message   Re: Bug in SBMLWriter  Andreas Dräger10 May '12 04:59
Previous Topic:Re: [sbml-render] Ids and names on elements
Next Topic:jsbml-svn commit list added
Go to forum:
-=] Back to Top [=-

Powered by FUDforum. (Copyright Advanced Internet Designs Inc.)

Please use our issue tracking system for any questions or suggestions about this website.