StochPy Basics

In [8]:
"""
Written by TR Maarleveld, Amsterdam, The Netherlands
E-mail: tmd200@users.sourceforge.net
Last Change: August 10, 2015
"""

import stochpy
smod = stochpy.SSA()
# required for iPython Notebook inline plotting
%matplotlib inline 

Do your first Stochastic simulation

We start by doing a stochastic simulation with the default StochPy settings. This means we start by simulating the Immigration Death model with the direct method for 1000 time steps.
In [9]:
smod.DoStochSim()
smod.PlotSpeciesTimeSeries()

Modify parameters

StochPy allows interactive modification of model parameters, which we illustrate here. It is of course also possible to modify the model file and reload the model.
In [10]:
smod.ChangeInitialSpeciesCopyNumbers('mRNA',100)
smod.DoStochSim()
smod.PlotSpeciesTimeSeries()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-10-74460e643266> in <module>()
----> 1 smod.ChangeInitialSpeciesCopyNumbers('mRNA',100)
      2 smod.DoStochSim()
      3 smod.PlotSpeciesTimeSeries()

AttributeError: SSA instance has no attribute 'ChangeInitialSpeciesCopyNumbers'
In [*]:
smod.ChangeParameter('Ksyn',10)
smod.ChangeParameter('Kdeg',0.1)
smod.DoStochSim()
smod.PlotSpeciesTimeSeries()
Info: 1 trajectory is generated
simulation done!               
Info: Number of time steps 1000 End time 54.9530559957
Info: Simulation time 0.101769924164

Select a different algorithm and model

StochPy provides many different stochastic simulation algorithms which we can divide in the following categories: 1) exact SSAs 2) inexact SSA 3) exact SSAs with delay 4) single molecule methods The exact SSAs are most used, but suffer typically from extensive running times. Inexaxt SSAs (i.e. tau-leaping) can be an outcome when exact SSAs are too slow for the job. We illustrate this here for the "DecayingDimerizing" model. The simulation with an exact solver is about 50 times slower. Remember that using tau-leaping methods result in loss of information (e.g. waiting times cannot be calculated). Exact SSAs with delay and single molecule methods are discussed in a different iPython notebook
In [11]:
smod.Model('DecayingDimerizing.psc')
smod.DoStochSim(method='tauleaping',end=50,mode='time')
smod.PlotSpeciesTimeSeries()
In [17]:
 
In [ ]: