Take the 2-minute tour ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

I'm looking for a decent implementation of Gillespie's Direct Method in Python, as if I code the algorithm myself I'm nigh positive I'll do it inefficiently.

Anyone have a favorite?

share|improve this question

3 Answers 3

up vote 4 down vote accepted

(Disclaimer: I haven't used any of the packages or code below.)

Finding any implementation of Gillespie's method in Python was a bit of a challenge; the most fruitful search terms seemed to be "tau leap" or "kinetic Monte Carlo." This blog post implements Gillespie's algorithm, though it's not clear that it's efficient. One of the commenters mentions some other Gillespie/SSA algorithm implementations in Python that solve problems out of a textbook; the relevant problems are 6.3 through 6.6 on this website.

The most promising implementations in Python that I found were StochPy and Python language bindings to COPASI. I also found what looked like promising C++ codes in SPPARKS, STOCKS, and StochKit; they're not Python, but maybe you can wrap around one of them in Python if it looks particularly promising to you.

share|improve this answer

I would warmly recommend to use StochKit, which is really extremely reliable and efficient. It implements the Gillespie's direct method as well as its most popular optimized variants. Furthermore, it has a built-in mechanism for selecting the appropriate simulation scheme depending on your network.

However, it is written in C++. If you really need to integrate it with a Python, that shouldn't be a problem. I use it extensively in MATLAB scripts (basically, MATLAB writes a descriptor of the simulation, calls StochKit, and finally performs the data analysis). I'm sure you could do pretty much the same thing with NumPy or SciPy.

share|improve this answer

As you may already know if you're asking this question, Gillespie's method is often used in computational systems biology. There are a number of software system that provide implementations; you may want to browse the SBML Software Guide to find some of them (specifically, the ones that are known to support SBML, something that I realize may not be relevant to your needs). However, Geoff Oxberry is correct that Python-based implementations of Gillespie's algorithms seem to be uncommon compared to C++ and Java implementations. In addition to StochPy, I'm aware of the following Python-based packages (in alphabetical order):

If, in your application, you can use software that's coded in something other than Python but can be wrapped with a Python interface, then there is

  • Cain — the core is C++, but it includes a Python-based interface
  • COPASI language bindings
  • several more options as mentioned by Geoff Oxberry in his reply on this page

Finally, if you don't need your simulation to be run locally and can instead use web services, then there are the following options:

  • BASIS
  • (the simulation service is currently off-line, but will return) SBW
  • ByoDyn's online services (see link above)

These lists are still incomplete, but hopefully they will help.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.