fbergmann / libSEDML

SED-ML library based on libSBML
BSD 2-Clause "Simplified" License
9 stars 12 forks source link

Can't call DependentVariable functions #140

Closed luciansmith closed 3 years ago

luciansmith commented 3 years ago

A DependentVariable differs from a Variable in that it also has the attributes 'symbol2', 'target2', and 'term'.

However, when I read it in and call getVariable from its parent DataGenerator, I am unable to interact with those attributes. Here's a small python script that demonstrates the problem:


import libsedml

doc = libsedml.readSedMLFromFile("rateOfChange.sedml")
dg = doc.getDataGenerator(3)
var = dg.getVariable(0)
print("SedVariable:", libsedml.SEDML_VARIABLE)
print("SedDependentVariable:", libsedml.SEDML_DEPENDENTVARIABLE)
print("Var type code: ", var.getTypeCode())

print("symbol: ", var.getSymbol())

try:
    print("symbol2:", var.getSymbol2())
except:
    print("unable to call 'getSymbol2'.")

[rateOfChange.sedml.txt](https://github.com/fbergmann/libSEDML/files/6534906/rateOfChange.sedml.txt)
fbergmann commented 3 years ago

thanks for the report, looking at this now.

fbergmann commented 3 years ago

By the way, i would have expected dependentVariable to be used differently. In this case i would expect instead of:

    <dependentVariable id="S1" symbol="urn:sedml:symbol:rateOfChange" target="/sbml:sbml/sbml:model/sbml:listOfSpecies/sbml:species[@id=&apos;S1&apos;]" taskReference="task0" modelReference="model0" symbol2="urn:sedml:symbol:time"/>

i would want:

    <dependentVariable id="S1" 
      taskReference="task0" <-- really only this one as the model becomes aparent from there
      modelReference="model0" <-- but ok 
      term="urn:sedml:symbol:rateOfChange" <-- rather than symbol1
      target="/sbml:sbml/sbml:model/sbml:listOfSpecies/sbml:species[@id=&apos;S1&apos;]"
      symbol2="urn:sedml:symbol:time"
    />

especially, since term would be a required attribute, so it does get flagged as invalid sedml (though the error message does require rewording, to indicate that variable attributes would have been allowed):

A <dependentVariable> object must have the required attribute 'sedml:term', and may have the optional attributes 'sedml:targetTwo' and 'sedml:symbolTwo'. No other attributes from the SBML Level 3 SED-ML namespaces are permitted on a <dependentVariable> object. 
fbergmann commented 3 years ago

Version 2.0.20 on pypi now.

luciansmith commented 3 years ago

Thanks for the quick response!

And yeah, after I went back and looked at the actual spec, I found the 'term' attribute and realized that was the more appropriate spot.