sbmlteam / python-libsbml

Standalone Python package containing libSBML with support for SBML Level 3 Core and accepted SBML Level 3 packages.
https://sbml.org/software/libsbml/
Other
21 stars 6 forks source link

Compile a ASTNode #14

Closed tonyxwz closed 4 years ago

tonyxwz commented 4 years ago

In my project, I need to compute the flux of a reaction. This can be done now by

formula = compile(kineticlaw.formula, "<string>", "eval")
# then
eval(formula, {}, context)

This is ok, but might affect the speed of the program. Is there any other way to do this? I just couldn't find it in the python api guide.

Thanks.

mhucka commented 4 years ago

Hi – Indeed, this is one way to do it. As you no doubt realize, interpreting the mathematical expressions becomes a bottleneck in simulations. There are off-the-shelf libraries and solvers that implement faster methods for SBML models, and I can try to point you to some. Can you explain just a little bit more about your situation? In particular, (1) are you using the flux balance constraints package in SBML or just plain core SBML, (2) which Level/Version of SBML are you using, and (3) in your case, is it an option to call an external library, or must it all be pure Python?

tonyxwz commented 4 years ago

Hi @mhucka , thanks for you reply

A bit more about my situation. My project is to develop a toolbox to improve the parameters in a SBML model. It involves dividing the simulation into small steps and optimize the parameters in each iteration.

  1. I am not using the flux balance constraints packages. My model is a ODE model and I need to calculate the fluxes to calculate the derivatives in the system of ODE.
  2. I am using the latest python-libsbml. But the model document is at Level 2. More specifically, I am testing on BioModels: 380 by Smallbone et al..
  3. I don't mind at all using an external library. But I prefer it at least can be called from python using subprocess and specify the parameters, since the parameter need to be changed between each iteration.
  4. The parameters I need to optimize are the ones in the kinetic law under reaction node, not only those under model node. So it might be important to be able to specify which Vmax, if there are many Vmaxs in different reactions.

Please point me to any library you come up with. Thanks again.

mhucka commented 4 years ago

Thanks for all those details! In this case, the following options are what come to mind first, in no particular order:

The above are pretty complete systems with a lot of documentation, but they may or may not have the capabilities you need to interact with the parameters in the kinetic laws. If you are able to take a look and if none of the above work out, then if you can let us how they don't suffice, I'll try to think of more options!

tonyxwz commented 4 years ago

I used COPASI in my university, but only with GUI. I will checkout libRoadRunner, it seems more promising. I will update here once I finished this project. Thanks!