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

"CupSodaSimulator doesn't support model with expression" error. #515

Open
lmriccardo opened this issue Aug 13, 2020 · 6 comments
Open

"CupSodaSimulator doesn't support model with expression" error. #515

lmriccardo opened this issue Aug 13, 2020 · 6 comments

Comments

@lmriccardo
Copy link

Hi, I've a problem simulating this model BIOMD0000000005 using the cupsoda simulator. I wrote this simple python script

from pysb.importers.sbml import model_from_sbml
from pysb.simulator.cupsoda import CupSodaSimulator
from pysb.pathfinder import set_path

filename = "BIOMD0000000005_url.xml"
model = model_from_sbml(filename=filename)
set_path("cupsoda", "path_to_cupSODA_directory")
simulator = CupSodaSimulator(model=model, tspan=range(0, 5))
result = simulator.run().dataframe

and the error is

Traceback (most recent call last):
  File "main.py", line 8, in <module>
    result = simulator.run().dataframe
  File "/home/riccbrand/anaconda3/lib/python3.6/site-packages/pysb/simulator/cupsoda.py", line 346, in run
    cmtx = self._get_cmatrix()
  File "/home/riccbrand/anaconda3/lib/python3.6/site-packages/pysb/simulator/cupsoda.py", line 583, in _get_cmatrix
    raise ValueError('cupSODA does not currently support '
ValueError: cupSODA does not currently support models with Expressions

Some general informations:

  • Python version: 3.6.2 with Anaconda
  • cupSODA created with nvcc with arch=6.1
  • GPU: Nvidia GeForce MX150

Where I'm wrong? I don't understand!
Thansk to everyone!!!

@JamesPino
Copy link
Contributor

cupSODA generates the ODEs from the the stoichiometry matrix from the reactions, so expressions, so it does not support the use of expressions.
Does the SMBL model have expressions? It might be the case that the expressions are generated using atomizer, but might not be required. I will try to see what is going on with the importer.

@lmriccardo
Copy link
Author

lmriccardo commented Aug 13, 2020

cupSODA generates the ODEs from the the stoichiometry matrix from the reactions, so expressions, so it does not support the use of expressions.
Does the SMBL model have expressions? It might be the case that the expressions are generated using atomizer, but might not be required. I will try to see what is going on with the importer.

@JamesPino I changed the script to print the expressions imported with the model and I get that

Cattura

So I think that model has expressions.

@JamesPino
Copy link
Contributor

It seems that the way the sbml is written and how it is converted to pysb (through bngl), the only way to do it safely is to use expressions.

For example, for a reaction A -> B with a rate constant k, the ratelaw in SBML is k*[A]. In BNG, we need to pull out the k from the ratelaw, so Atomizer tries to divide out the concentration [A] from it. Sometimes there’s a danger of divide-by-zero, so it makes a function like if(A>0, ratelaw/[A], 0). My guess is that’s the problem they’re running into.

After converting the model is pysb you can export to a file, then edit out the expressions.

model = model_from_sbml(filename=filename)
from pysb.export import export
with open('tyson_model.py', 'w') as f:
    f.write(export(model, 'pysb_flat',))

Sadly, it looks like this is the only way since cupSODA doesn't handle expressions, and SBML encodes the model with ratelaws. I can't think of another solution. The Tyson model you are using should be the same that is in pysb.examples.tyson_oscillator

@lmriccardo
Copy link
Author

@JamesPino Okay Thanks. After exporting in a new file, like did you do, how can I run a cupSODA simulation? Because it gives me the same error...

@JamesPino
Copy link
Contributor

So you'll have to modify that file to remove expressions. I am not sure your experience building models, but basically you have to add reactions corresponding to those expressions.

Is your project to start from SBML or are you just trying to use that model? I honestly don't know if it is easier to create the model from the information on biomodels from scratch or modify the exported file. Either way, the exported file should give you the monomer species and parameters, then its just creating the reactions from there.
https://www.ebi.ac.uk/biomodels/BIOMD0000000005#Components

If your goal is just to use that model for analysis, then you might be able to make the PySB implementation of it work for you.

There are still a lot of issues to be worked out to convert SBML models to rule based models in a robust way.

@lmriccardo
Copy link
Author

@JamesPino Unfortunatelly I'm not exeperinced in building model from scratch, so I don't know how to fix this problem. In these days I tried to learn something abou, but still I don't understand how to build reactions from expressions. Do you have any idea ?

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

2 participants