sbmlteam / jsbml

JSBML is a community-driven project to create a free, open-source, pure Java™ library for reading, writing, and manipulating SBML files (the Systems Biology Markup Language) and data streams. It is an alternative to the mixed Java/native code-based interface provided in libSBML.

Home Page:https://sbml.org/software/jsbml/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

model attributes

mephenor opened this issue · comments

There is a problem when I try to import the attributes areaUnits, substanceUnits, timeUnits, lengthUnits and
volumeUnits of a model object. The values that are set in the file won't be imported. When I use the code fragment

if(model.isSetAreaUnits())){
AttributeHelper.setAttribute(g, SBML_Constants.SBML, SBML_Constants.AREA_UNITS, areaUnits);

}

then there will be imported a value, but not the correct one. The predefined value "area" is imported. The problem with
the other attributes is analog.

I think that there is a problem when the sbmlDocument object is created from a file. The prededined values are set but
not the values of the file.

Reported by: *anonymous

You would have to be more specific of what is not working for you there.

Here is the code I tried :

// Setup : creating some simple objects
SBMLDocument doc = new SBMLDocument(3,1);

Model m = doc.createModel("model1");

m.setExtentUnits(Unit.Kind.MOLE.toString().toLowerCase());

m.setVolumeUnits("volume");

System.out.println("Model units = " + m.getVolumeUnits() + ", " + m.getExtentUnits());

m.getExtentUnitsInstance();
m.getVolumeUnitsInstance();

try {
new SBMLWriter().write(doc, "testModelUnits.xml");

SBMLDocument doc2 = new SBMLReader().readSBML("testModelUnits.xml");

System.out.println("Second Doc : model extend = " + doc2.getModel().getExtentUnits());
System.out.println("Second Doc : model volume = " + doc2.getModel().getVolumeUnits());

System.out.println("Second Doc : model extend UD = " + doc2.getModel().getExtentUnitsInstance());

} catch (SBMLException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (XMLStreamException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

And it seems that everything look normal. I did not try to refer to a defined UnitDefinition but I don't things that it should change anything.

I am not sure what the AttributeHelper class is doing but you should never have to use some external class to set the attributes of JSBML objects, just using the getter and setter provided should be sufficient and the attributes will be written to the file.

Original comment by: niko-rodrigue

  • milestone: --> jsbml 0.8
  • assigned_to: nobody --> niko-rodrigue
  • status: open --> open-works-for-me

Original comment by: niko-rodrigue

This was my fault, i am very sorry. I mixed the specifications and got a strange result. It was my mistake, JSBML works fine.

Original comment by: nobody

  • status: open-works-for-me --> closed-works-for-me

Original comment by: niko-rodrigue