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

Unable to import SBM files with Dependent variables #936

Closed
TorkelE opened this issue Apr 7, 2023 · 2 comments
Closed

Unable to import SBM files with Dependent variables #936

TorkelE opened this issue Apr 7, 2023 · 2 comments
Assignees
Labels
bug Something isn't working ✔️​ Issue / PR has been resolved
Milestone

Comments

@TorkelE
Copy link

TorkelE commented Apr 7, 2023

I am trying to load a SBML file using:

model_BCR = gillespy2.core.import_SBML('BCR.xml')[0]

However, I get an error:

Output exceeds the [size limit](command:workbench.action.openSettings?%5B%22notebook.output.textLineLimit%22%5D). Open the full output data [in a text editor](command:workbench.action.openLargeOutput?5525f57f-5dc7-4aab-9af7-88b7e334db90)
---------------------------------------------------------------------------
ParameterError                            Traceback (most recent call last)
File [~/.local/lib/python3.10/site-packages/gillespy2/core/model.py:305](https://file+.vscode-resource.vscode-cdn.net/home/torkelloman/Desktop/Writing/Catalyst-Fast-Biochemical-Modeling-with-Julia/Benchmarks/GillesPy2/~/.local/lib/python3.10/site-packages/gillespy2/core/model.py:305), in Model._resolve_parameter(self, parameter)
    304 try:
--> 305     parameter.validate()
    307     # Calculate the parameters value.

File [~/.local/lib/python3.10/site-packages/gillespy2/core/parameter.py:124](https://file+.vscode-resource.vscode-cdn.net/home/torkelloman/Desktop/Writing/Catalyst-Fast-Biochemical-Modeling-with-Julia/Benchmarks/GillesPy2/~/.local/lib/python3.10/site-packages/gillespy2/core/parameter.py:124), in Parameter.validate(self, expression, coverage)
    123 if not isinstance(expression, str):
--> 124     raise ParameterError("expression must be of type str, float, or int.")
    125 if expression == "":

ParameterError: expression must be of type str, float, or int.

The above exception was the direct cause of the following exception:

ModelError                                Traceback (most recent call last)
File [~/.local/lib/python3.10/site-packages/gillespy2/core/model.py:1295](https://file+.vscode-resource.vscode-cdn.net/home/torkelloman/Desktop/Writing/Catalyst-Fast-Biochemical-Modeling-with-Julia/Benchmarks/GillesPy2/~/.local/lib/python3.10/site-packages/gillespy2/core/model.py:1295), in Model.run(self, solver, timeout, t, increment, algorithm, **solver_args)
   1294 try:
-> 1295     return solver.run(t=t, increment=increment, timeout=timeout, **solver_args)
   1296 except Exception as err:

File [~/.local/lib/python3.10/site-packages/gillespy2/solvers/numpy/ode_solver.py:160](https://file+.vscode-resource.vscode-cdn.net/home/torkelloman/Desktop/Writing/Catalyst-Fast-Biochemical-Modeling-with-Julia/Benchmarks/GillesPy2/~/.local/lib/python3.10/site-packages/gillespy2/solvers/numpy/ode_solver.py:160), in ODESolver.run(self, model, t, number_of_trajectories, increment, integrator, integrator_options, live_output, live_output_options, timeout, resume, **kwargs)
    158     self.model = copy.deepcopy(model)
--> 160 self.model.compile_prep()
...
-> 1297     raise SimulationError(
   1298         f"argument 'solver={solver}' to run() failed.  Reason Given: {err}"
   1299     ) from err

SimulationError: argument 'solver=' to run() failed.  Reason Given: Could not add/resolve parameter: BT, Reason given: expression must be of type str, float, or int.

If I check the file, the problem seems to occur here:


    <listOfParameters>
      <!-- Independent variables -->
      <parameter id="p1" value="300000"/>
      <parameter id="p2" value="10"/>
      <parameter id="p3" value="0.0003"/>
      <parameter id="p4" value="3e-07"/>
      <parameter id="p5" value="30"/>
      <parameter id="p6" value="3e-05"/>
      <parameter id="p7" value="0.3"/>
      <parameter id="p8" value="0.1"/>
      <parameter id="p9" value="3e-06"/>
      <parameter id="p10" value="0.3"/>
      <parameter id="p11" value="1e-05"/>
      <parameter id="p12" value="1000"/>
      <parameter id="p13" value="30"/>
      <parameter id="p14" value="0.1"/>
      <parameter id="p15" value="3e-07"/>
      <parameter id="p16" value="0.003"/>
      <parameter id="p17" value="1e-10"/>
      <parameter id="p18" value="1e-07"/>
      <parameter id="p19" value="1e-07"/>
      <parameter id="p20" value="3e-05"/>
      <parameter id="p21" value="1000"/>
      <parameter id="p22" value="3e-06"/>
      <parameter id="p23" value="0.0003"/>
      <parameter id="p24" value="1"/>
      <parameter id="p25" value="5"/>
      <parameter id="c" value="3"/>
      <parameter id="kp16b" value="0"/>
      <!-- Dependent variables -->
      <parameter id="BT" constant="true"/>
      <parameter id="LT" constant="true"/>
      <parameter id="FT" constant="true"/>
      <parameter id="PT" constant="true"/>
      <parameter id="CT" constant="true"/>
      <parameter id="ST" constant="true"/>

where it cannot handle the <parameter id="BT" constant="true"/>

Is there a way around this, enabling me to load this model? I have been able to load this model using BioNetGen, so the file seems fine. Alternatively, I have the model in .bngl and .net form, if there's a way to load these into GillesPy2?

@BryanRumsey BryanRumsey self-assigned this Apr 7, 2023
@BryanRumsey BryanRumsey added bug Something isn't working ✔️​ Issue / PR has been resolved labels Apr 7, 2023
@BryanRumsey BryanRumsey added this to the 1.8.2 Release milestone Apr 7, 2023
@BryanRumsey
Copy link
Contributor

Thank you for reporting this issue. This issue will be resolved in the v1.8.2 release. The easiest way to work around this issue is to place this block after your SBML import.

for name, param in model_BCR.listOfParameters.items():
    param.expression = str(param.expression)

@TorkelE
Copy link
Author

TorkelE commented Apr 7, 2023

Thank you for the help :)

@TorkelE TorkelE closed this as completed Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ✔️​ Issue / PR has been resolved
Projects
None yet
Development

No branches or pull requests

2 participants