Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to simulate an SBML model (Species does not have a compartment attribute!) #592

Open
TorkelE opened this issue Mar 12, 2024 · 0 comments

Comments

@TorkelE
Copy link

TorkelE commented Mar 12, 2024

I have a model stored in a sbml file. I want to simulate it using NFSim:

import pysb
import numpy as np
from pysb.importers.sbml import model_from_sbml
from pysb.examples import robertson
from pysb.simulator.bng import BngSimulator

# Perform simulation.
model = model_from_sbml("../Data/multistate.xml")
sim = BngSimulator(model, tspan=np.linspace(0, 1))
x = sim.run(n_runs=1, method='nf')

Here, the last line gives an error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/anaconda3/lib/python3.11/site-packages/pysb/simulator/bng.py", line 211, in run
    bngfile.execute()
  File "/home/user/anaconda3/lib/python3.11/site-packages/pysb/bng.py", line 474, in execute
    raise BngInterfaceError('\n'.join(captured_error_lines) + "\n" +
pysb.bng.BngInterfaceError: 
ABORT: Species does not have a compartment attribute! at line 3 of file ./pysb0.species
  at line 100

I am unsure how to deal with this. I have pasted the sbml file below, if that is useful. I have been able to load and simualte this file using E.g. RoadRunner and SBMLToolkit, so I think the file should be fine.

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by BioNetGen 2.7.0  -->
<sbml xmlns="http://www.sbml.org/sbml/level2/version3" level="2" version="3">
  <model id="multistate">
    <listOfUnitDefinitions>
      <unitDefinition id="substance" name="substance">
        <listOfUnits>
          <unit kind="item" exponent="1" multiplier="1"/>
        </listOfUnits>
      </unitDefinition>
    </listOfUnitDefinitions>
    <listOfCompartments>
      <compartment id="cell" size="1"/>
    </listOfCompartments>
    <listOfSpecies>
      <species id="S1" compartment="cell" initialAmount="5360" name="R(a,l)"/>
      <species id="S2" compartment="cell" initialAmount="1160" name="L(r)"/>
      <species id="S3" compartment="cell" initialAmount="5360" name="A(Y~U,r)"/>
      <species id="S4" compartment="cell" initialAmount="0" name="L(r!1).R(a,l!1)"/>
      <species id="S5" compartment="cell" initialAmount="0" name="A(Y~U,r!1).R(a!1,l)"/>
      <species id="S6" compartment="cell" initialAmount="0" name="A(Y~U,r!1).L(r!2).R(a!1,l!2)"/>
      <species id="S7" compartment="cell" initialAmount="0" name="A(Y~P,r!1).L(r!2).R(a!1,l!2)"/>
      <species id="S8" compartment="cell" initialAmount="0" name="A(Y~P,r!1).R(a!1,l)"/>
      <species id="S9" compartment="cell" initialAmount="0" name="A(Y~P,r)"/>
    </listOfSpecies>
    <listOfParameters>
      <!-- Independent variables -->
      <parameter id="R0" value="5360"/>
      <parameter id="L0" value="1160"/>
      <parameter id="A0" value="5360"/>
      <parameter id="kon" value="0.01"/>
      <parameter id="koff" value="0.1"/>
      <parameter id="kAon" value="0.01"/>
      <parameter id="kAoff" value="0.1"/>
      <parameter id="kAp" value="0.01"/>
      <parameter id="kAdp" value="0.1"/>
      <!-- Observables -->
      <parameter id="A_P" constant="false"/>
      <parameter id="A_unbound_P" constant="false"/>
      <parameter id="A_bound_P" constant="false"/>
      <parameter id="RLA_P" constant="false"/>
    </listOfParameters>
    <listOfRules>
      <!-- Observables -->
      <assignmentRule variable="A_P">
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <plus/>
              <ci> S7 </ci>
              <ci> S8 </ci>
              <ci> S9 </ci>
            </apply>
          </math>
      </assignmentRule>
      <assignmentRule variable="A_unbound_P">
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <plus/>
              <cn> 0 </cn>
              <ci> S9 </ci>
            </apply>
          </math>
      </assignmentRule>
      <assignmentRule variable="A_bound_P">
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <plus/>
              <ci> S7 </ci>
              <ci> S8 </ci>
            </apply>
          </math>
      </assignmentRule>
      <assignmentRule variable="RLA_P">
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <plus/>
              <cn> 0 </cn>
              <ci> S7 </ci>
            </apply>
          </math>
      </assignmentRule>
    </listOfRules>
    <listOfReactions>
      <reaction id="R1" reversible="false">
        <listOfReactants>
          <speciesReference species="S1"/>
          <speciesReference species="S2"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S4"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kon </ci>
              <ci> S1 </ci>
              <ci> S2 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R2" reversible="false">
        <listOfReactants>
          <speciesReference species="S1"/>
          <speciesReference species="S3"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S5"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kAon </ci>
              <ci> S1 </ci>
              <ci> S3 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R3" reversible="false">
        <listOfReactants>
          <speciesReference species="S2"/>
          <speciesReference species="S5"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S6"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kon </ci>
              <ci> S2 </ci>
              <ci> S5 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R4" reversible="false">
        <listOfReactants>
          <speciesReference species="S4"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S1"/>
          <speciesReference species="S2"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> koff </ci>
              <ci> S4 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R5" reversible="false">
        <listOfReactants>
          <speciesReference species="S3"/>
          <speciesReference species="S4"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S6"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kAon </ci>
              <ci> S3 </ci>
              <ci> S4 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R6" reversible="false">
        <listOfReactants>
          <speciesReference species="S5"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S1"/>
          <speciesReference species="S3"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kAoff </ci>
              <ci> S5 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R7" reversible="false">
        <listOfReactants>
          <speciesReference species="S6"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S2"/>
          <speciesReference species="S5"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> koff </ci>
              <ci> S6 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R8" reversible="false">
        <listOfReactants>
          <speciesReference species="S6"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S3"/>
          <speciesReference species="S4"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kAoff </ci>
              <ci> S6 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R9" reversible="false">
        <listOfReactants>
          <speciesReference species="S6"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S7"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kAp </ci>
              <ci> S6 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R10" reversible="false">
        <listOfReactants>
          <speciesReference species="S7"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S2"/>
          <speciesReference species="S8"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> koff </ci>
              <ci> S7 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R11" reversible="false">
        <listOfReactants>
          <speciesReference species="S7"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S4"/>
          <speciesReference species="S9"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kAoff </ci>
              <ci> S7 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R12" reversible="false">
        <listOfReactants>
          <speciesReference species="S7"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S6"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kAdp </ci>
              <ci> S7 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R13" reversible="false">
        <listOfReactants>
          <speciesReference species="S2"/>
          <speciesReference species="S8"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S7"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kon </ci>
              <ci> S2 </ci>
              <ci> S8 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R14" reversible="false">
        <listOfReactants>
          <speciesReference species="S1"/>
          <speciesReference species="S9"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S8"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kAon </ci>
              <ci> S1 </ci>
              <ci> S9 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R15" reversible="false">
        <listOfReactants>
          <speciesReference species="S4"/>
          <speciesReference species="S9"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S7"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kAon </ci>
              <ci> S4 </ci>
              <ci> S9 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R16" reversible="false">
        <listOfReactants>
          <speciesReference species="S8"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S1"/>
          <speciesReference species="S9"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kAoff </ci>
              <ci> S8 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R17" reversible="false">
        <listOfReactants>
          <speciesReference species="S8"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S5"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kAdp </ci>
              <ci> S8 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
      <reaction id="R18" reversible="false">
        <listOfReactants>
          <speciesReference species="S9"/>
        </listOfReactants>
        <listOfProducts>
          <speciesReference species="S3"/>
        </listOfProducts>
        <kineticLaw>
          <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
              <times/>
              <ci> kAdp </ci>
              <ci> S9 </ci>
            </apply>
          </math>
        </kineticLaw>
      </reaction>
    </listOfReactions>
  </model>
</sbml>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant