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.
https://sbml.org/software/jsbml/
GNU Lesser General Public License v2.1
37 stars 24 forks source link

Errors in comp flattening routine (cannot register compartment, cannot register parameter) #213

Open matthiaskoenig opened 4 years ago

matthiaskoenig commented 4 years ago

When trying to flatten some simple comp models I get errors for the following files: comp.zip

Flattening is performed via

doc = SBMLReader.read(file);
CompFlatteningConverter compFlatteningConverter = new CompFlatteningConverter();
docFlat = compFlatteningConverter.flatten(doc);

E.g. for test10.xml one gets

May 19, 2020 2:53:12 PM org.sbml.jsbml.ext.comp.util.CompFlatteningConverter initSubModels
INFO: No model definition found in sub1.
May 19, 2020 2:53:12 PM org.sbml.jsbml.ext.comp.util.CompFlatteningConverter initSubModels
INFO: No model definition found in sub1.
ERROR (Model.java:4687) - An element of type compartment with the id "moddef1C" is already present in this model. The new element of type compartment will not have it's id set. In some cases, the new element will not be added to the model.

java.lang.IllegalArgumentException: Cannot register compartment.

    at org.sbml.jsbml.AbstractSBase.registerChild(AbstractSBase.java:2220)
    at org.sbml.jsbml.ListOf.add(ListOf.java:444)
    at org.sbml.jsbml.Model.addCompartment(Model.java:351)
    at org.sbml.jsbml.ext.comp.util.CompFlatteningConverter.mergeListsOfModels(CompFlatteningConverter.java:385)
    at org.sbml.jsbml.ext.comp.util.CompFlatteningConverter.mergeModels(CompFlatteningConverter.java:347)
    at org.sbml.jsbml.ext.comp.util.CompFlatteningConverter.flattenAndMergeModels(CompFlatteningConverter.java:304)
    at org.sbml.jsbml.ext.comp.util.CompFlatteningConverter.flattenAndMergeModels(CompFlatteningConverter.java:299)
    at org.sbml.jsbml.ext.comp.util.CompFlatteningConverter.initSubModels(CompFlatteningConverter.java:284)
    at org.sbml.jsbml.ext.comp.util.CompFlatteningConverter.initSubModels(CompFlatteningConverter.java:277)
    at org.sbml.jsbml.ext.comp.util.CompFlatteningConverter.instantiateSubModels(CompFlatteningConverter.java:153)
    at org.sbml.jsbml.ext.comp.util.CompFlatteningConverter.flatten(CompFlatteningConverter.java:115)
    at org.simulator.comp.CompSimulator.<init>(CompSimulator.java:43)
    at org.simulator.comp.CompSimulatorTest.testComp(CompSimulatorTest.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runners.Suite.runChild(Suite.java:127)
    at org.junit.runners.Suite.runChild(Suite.java:26)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runners.Suite.runChild(Suite.java:127)
    at org.junit.runners.Suite.runChild(Suite.java:26)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

For test6.xml one gets

ERROR (Model.java:4687) - An element of type parameter with the id "Mod1subparam2" is already present in this model. The new element of type parameter will not have it's id set. In some cases, the new element will not be added to the model.

java.lang.IllegalArgumentException: Cannot register parameter.

    at org.sbml.jsbml.AbstractSBase.registerChild(AbstractSBase.java:2220)
    at org.sbml.jsbml.ListOf.add(ListOf.java:444)
    at org.sbml.jsbml.Model.addParameter(Model.java:434)
    at org.sbml.jsbml.ext.comp.util.CompFlatteningConverter.mergeListsOfModels(CompFlatteningConverter.java:451)
    at org.sbml.jsbml.ext.comp.util.CompFlatteningConverter.mergeModels(CompFlatteningConverter.java:354)
    at org.sbml.jsbml.ext.comp.util.CompFlatteningConverter.flattenAndMergeModels(CompFlatteningConverter.java:304)
    at org.sbml.jsbml.ext.comp.util.CompFlatteningConverter.initSubModels(CompFlatteningConverter.java:284)
    at org.sbml.jsbml.ext.comp.util.CompFlatteningConverter.instantiateSubModels(CompFlatteningConverter.java:153)
    at org.sbml.jsbml.ext.comp.util.CompFlatteningConverter.flatten(CompFlatteningConverter.java:115)
    at org.simulator.comp.CompSimulator.<init>(CompSimulator.java:43)
    at org.simulator.comp.CompSimulatorTest.testComp(CompSimulatorTest.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runners.Suite.runChild(Suite.java:127)
    at org.junit.runners.Suite.runChild(Suite.java:26)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runners.Suite.runChild(Suite.java:127)
    at org.junit.runners.Suite.runChild(Suite.java:26)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
matthiaskoenig commented 4 years ago

Hi all,

does anybody know what is going on here? This worked in earlier versions of JSBML and should be picked up by regression tests. When we worked 1-2 years ago with Shalin on the CompSimulation in SBSCL all these models flattened just fine.

What changed in the Comp flattening since then?

niko-rodrigue commented 4 years ago

a student worked on loading external model definition from all possible ways. He might have broken something for the flattening. There might not have been integrated tests for the comp flattening at the moment, so this went unnoticed.

On Thu, 28 May 2020 at 15:58, Matthias König notifications@github.com wrote:

Hi all,

does anybody know what is going on here? This worked in earlier versions of JSBML and should be picked up by regression tests. When we worked 1-2 years ago with Shalin on the CompSimulation in SBSCL all these models flattened just fine.

What changed in the Comp flattening since then?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sbmlteam/jsbml/issues/213#issuecomment-635403626, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMVB4L3BGYJ4LIZXJHDEEDRTZ3XXANCNFSM4NFA5XOA .

matthiaskoenig commented 4 years ago

Hi all, I will tackle this issue.

There are many test models in the repository, the failures were just not very obvious (2 failing tests). After creating some better tests (parametrized tests instead of one test running all test models) 54/60 comp test models cannot be flattened. If anybody gives me commit access to the repository I can push my changes in a branch and work on fixing the flattening issues.

Best Matthias

niko-rodrigue commented 4 years ago

Hi Matthias, good to hear. Andreas should be able to give you access if needed. But you can also fork the repo and do some push requests afterwards.

On Tue, 14 Jul 2020 at 20:18, Matthias König notifications@github.com wrote:

Hi all, I will tackle this issue.

There are many test models in the repository, the failures were just not very obvious (2 failing tests). After creating some better tests (parametrized tests instead of one test running all test models) 54/60 comp test models cannot be flattened. If anybody gives me commit access to the repository I can push my changes in a branch and work on fixing the flattening issues.

Best Matthias

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sbmlteam/jsbml/issues/213#issuecomment-658364452, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMVB4KW7P2KEXSMXCMOARDR3SVP5ANCNFSM4NFA5XOA .

draeger commented 4 years ago

@matthiaskoenig has been invited as a collaborator with write permission. Thanks, @niko-rodrigue and @matthiaskoenig!