If a species has an initialConcentration and lives in a compartment whose size is governed by an assignmentRule,
roadrunner initializes the species concentration to 0 instead of the stated value. The compartment size itself
comes out right. Only the species is wrong.
Here's a minimal case. X should start at 0.05 and the compartment V starts at 1, so nothing about the rule
changes the value at t=0:
import roadrunner
sbml = """<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
<model id="init_bug">
<listOfCompartments>
<compartment id="V" spatialDimensions="3" size="1" constant="false"/>
</listOfCompartments>
<listOfSpecies>
<species id="X" compartment="V" initialConcentration="0.05"
hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
</listOfSpecies>
<listOfRules>
<assignmentRule variable="V">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><plus/>
<cn type="integer">1</cn>
<csymbol encoding="text" definitionURL="http://www.sbml.org/sbml/symbols/time">time</csymbol>
</apply>
</math>
</assignmentRule>
</listOfRules>
</model>
</sbml>"""
rr = roadrunner.RoadRunner(sbml)
print(rr["[X]"], rr["V"]) # prints 0.0 1.0 ; expected 0.05 1.0
Expected [X] = 0.05. Actual is 0.0 (roadrunner 2.9.2).
A few things I narrowed down:
- It only happens when the compartment rule is time-dependent. Make the compartment constant, or give it an
assignmentRule with a constant value (which gets folded), and X comes out 0.05 as expected.
- The wrong value depends on the rule expression. V := 1 + time gives 0; V := 2/(1 + time) gives -inf; V := 2 +
0*time gives nan. So it looks like the species amount is being computed against a compartment volume that hasn't
been evaluated yet, rather than the initialConcentration being used directly.
- The compartment itself reads back correctly at t=0, so it's specifically the species initialization that's off.
I ran into this on the BioModels curated model BIOMD0000000342 (Zi 2012 TGF-beta), where the medium compartment Vmed
has an assignmentRule and the extracellular ligand TGF_beta_ex has initialConcentration 0.05. roadrunner loads
it as 0, which leaves the whole receptor cascade unstimulated.
If a species has an initialConcentration and lives in a compartment whose size is governed by an assignmentRule,
roadrunner initializes the species concentration to 0 instead of the stated value. The compartment size itself
comes out right. Only the species is wrong.
Here's a minimal case. X should start at 0.05 and the compartment V starts at 1, so nothing about the rule
changes the value at t=0:
rr = roadrunner.RoadRunner(sbml)
print(rr["[X]"], rr["V"]) # prints 0.0 1.0 ; expected 0.05 1.0
Expected [X] = 0.05. Actual is 0.0 (roadrunner 2.9.2).
A few things I narrowed down:
assignmentRule with a constant value (which gets folded), and X comes out 0.05 as expected.
0*time gives nan. So it looks like the species amount is being computed against a compartment volume that hasn't
been evaluated yet, rather than the initialConcentration being used directly.
I ran into this on the BioModels curated model BIOMD0000000342 (Zi 2012 TGF-beta), where the medium compartment Vmed
has an assignmentRule and the extracellular ligand TGF_beta_ex has initialConcentration 0.05. roadrunner loads
it as 0, which leaves the whole receptor cascade unstimulated.