| Author | Topic |
Posts: 273
Registered: June 2006
|
|
|
Posts: 307
Location: Cambridge UK
Registered: February 2005
|
|
Re: Bug in SBMLWriter
|
08 May '12 06:17

|
 |
|
On 08/05/12 13:57, Andreas Dräger wrote:
> |Hi all,
>
> It seems the SBML writer does currently write invalid SBML code when
> making use of the ability of SBML Level 3 to associate plain numbers
> with units:
>
> <cn type="integer" sbml:units="dimensionless"> 1</cn>
>
> The above code is only valid if the namespace declaration of the math
> element also defines
>
> xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"
>
> Currently, it does only declare the regular MathML namesapce. As a
> result, JSBML is currently unable to parse models that itself wrote into
> a file before. Where can we fix this problem?
The check is in
org.sbml.jsbml.util.compilers.MathMLXMLStreamCompiler.isSBMLNamespaceNeeded(ASTNode)
the namespace is added in
org.sbml.jsbml.xml.stax.SBMLWriter.writeMathML(MathContainer,
SMOutputElement, XMLStreamWriter, int)
line 1084 to 1106.
The compiler org.sbml.jsbml.util.compilers.FindUnitsCompiler is used to
say if there is a unit declaration or not in the mathML.
This is probably there that the problem happen, and the value returned
is probably false.
It is probably due to the way you are declaring the units and then how
the mathML compiler is calling the methods.
If I read a model with units, then the writing is fine so there is may
be something missing when we declare units from scratch.
Nico
> Cheers
> Andreas
> |
>
____________________________________________________________
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
|
|
|
Posts: 273
Registered: June 2006
|
|
Re: Bug in SBMLWriter
|
08 May '12 06:20

|
 |
|
Am 5/8/12 3:17 PM, schrieb Nicolas Rodriguez:
> On 08/05/12 13:57, Andreas Dräger wrote:
>> |Hi all,
>>
>> It seems the SBML writer does currently write invalid SBML code when
>> making use of the ability of SBML Level 3 to associate plain numbers
>> with units:
>>
>> <cn type="integer" sbml:units="dimensionless"> 1</cn>
>>
>> The above code is only valid if the namespace declaration of the math
>> element also defines
>>
>> xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"
>>
>> Currently, it does only declare the regular MathML namesapce. As a
>> result, JSBML is currently unable to parse models that itself wrote into
>> a file before. Where can we fix this problem?
> The check is in
> org.sbml.jsbml.util.compilers.MathMLXMLStreamCompiler.isSBMLNamespaceNeeded(ASTNode)
>
> the namespace is added in
> org.sbml.jsbml.xml.stax.SBMLWriter.writeMathML(MathContainer,
> SMOutputElement, XMLStreamWriter, int)
>
> line 1084 to 1106.
>
> The compiler org.sbml.jsbml.util.compilers.FindUnitsCompiler is used to
> say if there is a unit declaration or not in the mathML.
>
> This is probably there that the problem happen, and the value returned
> is probably false.
> It is probably due to the way you are declaring the units and then how
> the mathML compiler is calling the methods.
>
> If I read a model with units, then the writing is fine so there is may
> be something missing when we declare units from scratch.
>
>
Hi Nico,
Yes, it is probably because I simply say
myASTNode.setUnit(Unit.Kind.DIMENSIONLESS.getName());
or something similar. I thought this would be enough and didn't care
about namespaces at the moment.
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
|
|
|
Posts: 307
Location: Cambridge UK
Registered: February 2005
|
|
Re: Bug in SBMLWriter
|
08 May '12 06:30

|
 |
|
On 08/05/12 14:20, Andreas Dräger wrote:
> Am 5/8/12 3:17 PM, schrieb Nicolas Rodriguez:
>> On 08/05/12 13:57, Andreas Dräger wrote:
>>> |Hi all,
>>>
>>> It seems the SBML writer does currently write invalid SBML code when
>>> making use of the ability of SBML Level 3 to associate plain numbers
>>> with units:
>>>
>>> <cn type="integer" sbml:units="dimensionless"> 1</cn>
>>>
>>> The above code is only valid if the namespace declaration of the math
>>> element also defines
>>>
>>> xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"
>>>
>>> Currently, it does only declare the regular MathML namesapce. As a
>>> result, JSBML is currently unable to parse models that itself wrote into
>>> a file before. Where can we fix this problem?
>> The check is in
>> org.sbml.jsbml.util.compilers.MathMLXMLStreamCompiler.isSBMLNamespaceNeeded(ASTNode)
>>
>> the namespace is added in
>> org.sbml.jsbml.xml.stax.SBMLWriter.writeMathML(MathContainer,
>> SMOutputElement, XMLStreamWriter, int)
>>
>> line 1084 to 1106.
>>
>> The compiler org.sbml.jsbml.util.compilers.FindUnitsCompiler is used to
>> say if there is a unit declaration or not in the mathML.
>>
>> This is probably there that the problem happen, and the value returned
>> is probably false.
>> It is probably due to the way you are declaring the units and then how
>> the mathML compiler is calling the methods.
>>
>> If I read a model with units, then the writing is fine so there is may
>> be something missing when we declare units from scratch.
>>
>>
> Hi Nico,
>
> Yes, it is probably because I simply say
>
> myASTNode.setUnit(Unit.Kind.DIMENSIONLESS.getName());
>
> or something similar. I thought this would be enough and didn't care
> about namespaces at the moment.
It should be enough but it was probably not tested much until now.
We should probably check how the reader is setting things up.
Nico
____________________________________________________________
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
|
|
|
Posts: 307
Location: Cambridge UK
Registered: February 2005
|
|
Re: Bug in SBMLWriter
|
08 May '12 06:43

|
 |
|
On 08/05/12 14:30, Nicolas Rodriguez wrote:
> On 08/05/12 14:20, Andreas Dräger wrote:
>> Am 5/8/12 3:17 PM, schrieb Nicolas Rodriguez:
>>> On 08/05/12 13:57, Andreas Dräger wrote:
>>>> |Hi all,
>>>>
>>>> It seems the SBML writer does currently write invalid SBML code when
>>>> making use of the ability of SBML Level 3 to associate plain numbers
>>>> with units:
>>>>
>>>> <cn type="integer" sbml:units="dimensionless"> 1</cn>
>>>>
>>>> The above code is only valid if the namespace declaration of the math
>>>> element also defines
>>>>
>>>> xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"
>>>>
>>>> Currently, it does only declare the regular MathML namesapce. As a
>>>> result, JSBML is currently unable to parse models that itself wrote into
>>>> a file before. Where can we fix this problem?
>>> The check is in
>>> org.sbml.jsbml.util.compilers.MathMLXMLStreamCompiler.isSBMLNamespaceNeeded(ASTNode)
>>>
>>> the namespace is added in
>>> org.sbml.jsbml.xml.stax.SBMLWriter.writeMathML(MathContainer,
>>> SMOutputElement, XMLStreamWriter, int)
>>>
>>> line 1084 to 1106.
>>>
>>> The compiler org.sbml.jsbml.util.compilers.FindUnitsCompiler is used to
>>> say if there is a unit declaration or not in the mathML.
>>>
>>> This is probably there that the problem happen, and the value returned
>>> is probably false.
>>> It is probably due to the way you are declaring the units and then how
>>> the mathML compiler is calling the methods.
>>>
>>> If I read a model with units, then the writing is fine so there is may
>>> be something missing when we declare units from scratch.
>>>
>>>
>> Hi Nico,
>>
>> Yes, it is probably because I simply say
>>
>> myASTNode.setUnit(Unit.Kind.DIMENSIONLESS.getName());
>>
>> or something similar. I thought this would be enough and didn't care
>> about namespaces at the moment.
> It should be enough but it was probably not tested much until now.
>
> We should probably check how the reader is setting things up.
So, the reader is not doing anything specific, just using the setUnits()
method ( I suppose it was a typo error on your code as I don't see a
method setUnit().
Strange, it was working fine before.
Nico
____________________________________________________________
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
|
|
|
Posts: 307
Location: Cambridge UK
Registered: February 2005
|
|
Re: Bug in SBMLWriter
|
08 May '12 07:10

|
 |
|
On 08/05/12 14:43, Nicolas Rodriguez wrote:
> On 08/05/12 14:30, Nicolas Rodriguez wrote:
>> On 08/05/12 14:20, Andreas Dräger wrote:
>>> Am 5/8/12 3:17 PM, schrieb Nicolas Rodriguez:
>>>> On 08/05/12 13:57, Andreas Dräger wrote:
>>>>> |Hi all,
>>>>>
>>>>> It seems the SBML writer does currently write invalid SBML code when
>>>>> making use of the ability of SBML Level 3 to associate plain numbers
>>>>> with units:
>>>>>
>>>>> <cn type="integer" sbml:units="dimensionless"> 1</cn>
>>>>>
>>>>> The above code is only valid if the namespace declaration of the math
>>>>> element also defines
>>>>>
>>>>> xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"
>>>>>
>>>>> Currently, it does only declare the regular MathML namesapce. As a
>>>>> result, JSBML is currently unable to parse models that itself wrote into
>>>>> a file before. Where can we fix this problem?
>>>> The check is in
>>>> org.sbml.jsbml.util.compilers.MathMLXMLStreamCompiler.isSBMLNamespaceNeeded(ASTNode)
>>>>
>>>> the namespace is added in
>>>> org.sbml.jsbml.xml.stax.SBMLWriter.writeMathML(MathContainer,
>>>> SMOutputElement, XMLStreamWriter, int)
>>>>
>>>> line 1084 to 1106.
>>>>
>>>> The compiler org.sbml.jsbml.util.compilers.FindUnitsCompiler is used to
>>>> say if there is a unit declaration or not in the mathML.
>>>>
>>>> This is probably there that the problem happen, and the value returned
>>>> is probably false.
>>>> It is probably due to the way you are declaring the units and then how
>>>> the mathML compiler is calling the methods.
>>>>
>>>> If I read a model with units, then the writing is fine so there is may
>>>> be something missing when we declare units from scratch.
>>>>
>>>>
>>> Hi Nico,
>>>
>>> Yes, it is probably because I simply say
>>>
>>> myASTNode.setUnit(Unit.Kind.DIMENSIONLESS.getName());
>>>
>>> or something similar. I thought this would be enough and didn't care
>>> about namespaces at the moment.
>> It should be enough but it was probably not tested much until now.
>>
>> We should probably check how the reader is setting things up.
> So, the reader is not doing anything specific, just using the setUnits()
> method ( I suppose it was a typo error on your code as I don't see a
> method setUnit().
>
> Strange, it was working fine before.
Just checked it again using org.sbml.jsbml.ext.qual.BuildToyModelTest
And it is working fine for me.
Can you check which version of jsbml did you use to generate the models ?
Nico
____________________________________________________________
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
|
|
|
Posts: 273
Registered: June 2006
|
|
Re: Bug in SBMLWriter
|
09 May '12 11:42

|
 |
|
Am 5/8/12 3:43 PM, schrieb Nicolas Rodriguez:
> On 08/05/12 14:30, Nicolas Rodriguez wrote:
>> On 08/05/12 14:20, Andreas Dräger wrote:
>>> Am 5/8/12 3:17 PM, schrieb Nicolas Rodriguez:
>>>> On 08/05/12 13:57, Andreas Dräger wrote:
>>>>> |Hi all,
>>>>>
>>>>> It seems the SBML writer does currently write invalid SBML code when
>>>>> making use of the ability of SBML Level 3 to associate plain numbers
>>>>> with units:
>>>>>
>>>>> <cn type="integer" sbml:units="dimensionless"> 1</cn>
>>>>>
>>>>> The above code is only valid if the namespace declaration of the math
>>>>> element also defines
>>>>>
>>>>> xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"
>>>>>
>>>>> Currently, it does only declare the regular MathML namesapce. As a
>>>>> result, JSBML is currently unable to parse models that itself wrote into
>>>>> a file before. Where can we fix this problem?
>>>> The check is in
>>>> org.sbml.jsbml.util.compilers.MathMLXMLStreamCompiler.isSBMLNamespaceNeeded(ASTNode)
>>>>
>>>> the namespace is added in
>>>> org.sbml.jsbml.xml.stax.SBMLWriter.writeMathML(MathContainer,
>>>> SMOutputElement, XMLStreamWriter, int)
>>>>
>>>> line 1084 to 1106.
>>>>
>>>> The compiler org.sbml.jsbml.util.compilers.FindUnitsCompiler is used to
>>>> say if there is a unit declaration or not in the mathML.
>>>>
>>>> This is probably there that the problem happen, and the value returned
>>>> is probably false.
>>>> It is probably due to the way you are declaring the units and then how
>>>> the mathML compiler is calling the methods.
>>>>
>>>> If I read a model with units, then the writing is fine so there is may
>>>> be something missing when we declare units from scratch.
>>>>
>>>>
>>> Hi Nico,
>>>
>>> Yes, it is probably because I simply say
>>>
>>> myASTNode.setUnit(Unit.Kind.DIMENSIONLESS.getName());
>>>
>>> or something similar. I thought this would be enough and didn't care
>>> about namespaces at the moment.
>> It should be enough but it was probably not tested much until now.
>>
>> We should probably check how the reader is setting things up.
> So, the reader is not doing anything specific, just using the setUnits()
> method ( I suppose it was a typo error on your code as I don't see a
> method setUnit().
>
> Strange, it was working fine before.
>
>
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.
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
|
|
|
Posts: 307
Location: Cambridge UK
Registered: February 2005
|
|
Re: Bug in SBMLWriter
|
10 May '12 04:49

|
 |
|
On 09/05/12 19:42, Andreas Dräger wrote:
> Am 5/8/12 3:43 PM, schrieb Nicolas Rodriguez:
>> On 08/05/12 14:30, Nicolas Rodriguez wrote:
>>> On 08/05/12 14:20, Andreas Dräger wrote:
>>>> Am 5/8/12 3:17 PM, schrieb Nicolas Rodriguez:
>>>>> On 08/05/12 13:57, Andreas Dräger wrote:
>>>>>> |Hi all,
>>>>>>
>>>>>> It seems the SBML writer does currently write invalid SBML code when
>>>>>> making use of the ability of SBML Level 3 to associate plain numbers
>>>>>> with units:
>>>>>>
>>>>>> <cn type="integer" sbml:units="dimensionless"> 1</cn>
>>>>>>
>>>>>> The above code is only valid if the namespace declaration of the math
>>>>>> element also defines
>>>>>>
>>>>>> xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"
>>>>>>
>>>>>> Currently, it does only declare the regular MathML namesapce. As a
>>>>>> result, JSBML is currently unable to parse models that itself wrote into
>>>>>> a file before. Where can we fix this problem?
>>>>> The check is in
>>>>> org.sbml.jsbml.util.compilers.MathMLXMLStreamCompiler.isSBMLNamespaceNeeded(ASTNode)
>>>>>
>>>>> the namespace is added in
>>>>> org.sbml.jsbml.xml.stax.SBMLWriter.writeMathML(MathContainer,
>>>>> SMOutputElement, XMLStreamWriter, int)
>>>>>
>>>>> line 1084 to 1106.
>>>>>
>>>>> The compiler org.sbml.jsbml.util.compilers.FindUnitsCompiler is used to
>>>>> say if there is a unit declaration or not in the mathML.
>>>>>
>>>>> This is probably there that the problem happen, and the value returned
>>>>> is probably false.
>>>>> It is probably due to the way you are declaring the units and then how
>>>>> the mathML compiler is calling the methods.
>>>>>
>>>>> If I read a model with units, then the writing is fine so there is may
>>>>> be something missing when we declare units from scratch.
>>>>>
>>>>>
>>>> Hi Nico,
>>>>
>>>> Yes, it is probably because I simply say
>>>>
>>>> myASTNode.setUnit(Unit.Kind.DIMENSIONLESS.getName());
>>>>
>>>> or something similar. I thought this would be enough and didn't care
>>>> about namespaces at the moment.
>>> It should be enough but it was probably not tested much until now.
>>>
>>> We should probably check how the reader is setting things up.
>> So, the reader is not doing anything specific, just using the setUnits()
>> method ( I suppose it was a typo error on your code as I don't see a
>> method setUnit().
>>
>> Strange, it was working fine before.
>>
>>
> 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
____________________________________________________________
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
|
|
|
Posts: 307
Location: Cambridge UK
Registered: February 2005
|
|
Re: Bug in SBMLWriter
|
10 May '12 04:57

|
 |
|
On 10/05/12 12:49, Nicolas Rodriguez wrote:
> On 09/05/12 19:42, Andreas Dräger wrote:
>> Am 5/8/12 3:43 PM, schrieb Nicolas Rodriguez:
>>> On 08/05/12 14:30, Nicolas Rodriguez wrote:
>>>> On 08/05/12 14:20, Andreas Dräger wrote:
>>>>> Am 5/8/12 3:17 PM, schrieb Nicolas Rodriguez:
>>>>>> On 08/05/12 13:57, Andreas Dräger wrote:
>>>>>>> |Hi all,
>>>>>>>
>>>>>>> It seems the SBML writer does currently write invalid SBML code when
>>>>>>> making use of the ability of SBML Level 3 to associate plain numbers
>>>>>>> with units:
>>>>>>>
>>>>>>> <cn type="integer" sbml:units="dimensionless"> 1</cn>
>>>>>>>
>>>>>>> The above code is only valid if the namespace declaration of the math
>>>>>>> element also defines
>>>>>>>
>>>>>>> xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"
>>>>>>>
>>>>>>> Currently, it does only declare the regular MathML namesapce. As a
>>>>>>> result, JSBML is currently unable to parse models that itself wrote into
>>>>>>> a file before. Where can we fix this problem?
>>>>>> The check is in
>>>>>> org.sbml.jsbml.util.compilers.MathMLXMLStreamCompiler.isSBMLNamespaceNeeded(ASTNode)
>>>>>>
>>>>>> the namespace is added in
>>>>>> org.sbml.jsbml.xml.stax.SBMLWriter.writeMathML(MathContainer,
>>>>>> SMOutputElement, XMLStreamWriter, int)
>>>>>>
>>>>>> line 1084 to 1106.
>>>>>>
>>>>>> The compiler org.sbml.jsbml.util.compilers.FindUnitsCompiler is used to
>>>>>> say if there is a unit declaration or not in the mathML.
>>>>>>
>>>>>> This is probably there that the problem happen, and the value returned
>>>>>> is probably false.
>>>>>> It is probably due to the way you are declaring the units and then how
>>>>>> the mathML compiler is calling the methods.
>>>>>>
>>>>>> If I read a model with units, then the writing is fine so there is may
>>>>>> be something missing when we declare units from scratch.
>>>>>>
>>>>>>
>>>>> Hi Nico,
>>>>>
>>>>> Yes, it is probably because I simply say
>>>>>
>>>>> myASTNode.setUnit(Unit.Kind.DIMENSIONLESS.getName());
>>>>>
>>>>> or something similar. I thought this would be enough and didn't care
>>>>> about namespaces at the moment.
>>>> It should be enough but it was probably not tested much until now.
>>>>
>>>> We should probably check how the reader is setting things up.
>>> So, the reader is not doing anything specific, just using the setUnits()
>>> method ( I suppose it was a typo error on your code as I don't see a
>>> method setUnit().
>>>
>>> Strange, it was working fine before.
>>>
>>>
>> 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 unit that get deleted is probably due to the code from
org.sbml.jsbml.ASTNode.arithmeticOperation(Type, ASTNode) ??
The swap node does not copy the units ?
Nico
____________________________________________________________
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
|
|
|
Posts: 273
Registered: June 2006
|
|
Re: Bug in SBMLWriter
|
10 May '12 04:59

|
 |
|
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
|
|
|
Posts: 307
Location: Cambridge UK
Registered: February 2005
|
|
Re: Bug in SBMLWriter
|
10 May '12 05:38

|
 |
|
On 10/05/12 12:57, Nicolas Rodriguez wrote:
> On 10/05/12 12:49, Nicolas Rodriguez wrote:
>> On 09/05/12 19:42, Andreas Dräger wrote:
>>> Am 5/8/12 3:43 PM, schrieb Nicolas Rodriguez:
>>>> On 08/05/12 14:30, Nicolas Rodriguez wrote:
>>>>> On 08/05/12 14:20, Andreas Dräger wrote:
>>>>>> Am 5/8/12 3:17 PM, schrieb Nicolas Rodriguez:
>>>>>>> On 08/05/12 13:57, Andreas Dräger wrote:
>>>>>>>> |Hi all,
>>>>>>>>
>>>>>>>> It seems the SBML writer does currently write invalid SBML code when
>>>>>>>> making use of the ability of SBML Level 3 to associate plain numbers
>>>>>>>> with units:
>>>>>>>>
>>>>>>>> <cn type="integer" sbml:units="dimensionless"> 1</cn>
>>>>>>>>
>>>>>>>> The above code is only valid if the namespace declaration of the math
>>>>>>>> element also defines
>>>>>>>>
>>>>>>>> xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"
>>>>>>>>
>>>>>>>> Currently, it does only declare the regular MathML namesapce. As a
>>>>>>>> result, JSBML is currently unable to parse models that itself wrote into
>>>>>>>> a file before. Where can we fix this problem?
>>>>>>> The check is in
>>>>>>> org.sbml.jsbml.util.compilers.MathMLXMLStreamCompiler.isSBMLNamespaceNeeded(ASTNode)
>>>>>>>
>>>>>>> the namespace is added in
>>>>>>> org.sbml.jsbml.xml.stax.SBMLWriter.writeMathML(MathContainer,
>>>>>>> SMOutputElement, XMLStreamWriter, int)
>>>>>>>
>>>>>>> line 1084 to 1106.
>>>>>>>
>>>>>>> The compiler org.sbml.jsbml.util.compilers.FindUnitsCompiler is used to
>>>>>>> say if there is a unit declaration or not in the mathML.
>>>>>>>
>>>>>>> This is probably there that the problem happen, and the value returned
>>>>>>> is probably false.
>>>>>>> It is probably due to the way you are declaring the units and then how
>>>>>>> the mathML compiler is calling the methods.
>>>>>>>
>>>>>>> If I read a model with units, then the writing is fine so there is may
>>>>>>> be something missing when we declare units from scratch.
>>>>>>>
>>>>>>>
>>>>>> Hi Nico,
>>>>>>
>>>>>> Yes, it is probably because I simply say
>>>>>>
>>>>>> myASTNode.setUnit(Unit.Kind.DIMENSIONLESS.getName());
>>>>>>
>>>>>> or something similar. I thought this would be enough and didn't care
>>>>>> about namespaces at the moment.
>>>>> It should be enough but it was probably not tested much until now.
>>>>>
>>>>> We should probably check how the reader is setting things up.
>>>> So, the reader is not doing anything specific, just using the setUnits()
>>>> method ( I suppose it was a typo error on your code as I don't see a
>>>> method setUnit().
>>>>
>>>> Strange, it was working fine before.
>>>>
>>>>
>>> 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 unit that get deleted is probably due to the code from
> org.sbml.jsbml.ASTNode.arithmeticOperation(Type, ASTNode) ??
>
> The swap node does not copy the units ?
ok, both fixes are commited now and it should be working fine.
I suppose this a good case to de-freeze the 0.8 branch.
Should I commit there (in the 0.8 branch) the changes to
Model.registerIds as well ?
Nico
____________________________________________________________
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
|
|
|
Posts: 273
Registered: June 2006
|
|
Re: Bug in SBMLWriter
|
10 May '12 05:50
|
 |
|
Am 5/10/12 2:38 PM, schrieb Nicolas Rodriguez:
>
>>>> 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 unit that get deleted is probably due to the code from
>> org.sbml.jsbml.ASTNode.arithmeticOperation(Type, ASTNode) ??
>>
>> The swap node does not copy the units ?
> ok, both fixes are commited now and it should be working fine.
>
> I suppose this a good case to de-freeze the 0.8 branch.
>
> Should I commit there (in the 0.8 branch) the changes to
> Model.registerIds as well ?
>
Hi Nico,
Thank you a lot for your great job! Yes, I agree, please do a commit
here! This is an absolutely necessary change.
Best
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
|
|
|
|