# StochPy Interfaces: CAIN and StochKit 2¶

StochPy provides interface to both the CAIN and StochKit 2 solvers. This can offer significant speed benefits, but be very careful using them if you are new to stochastic algorithms. Both methods "frame" their output, which can allow for less data storage and therefore significantly faster simulations. This is very beneficial if one is only interested in time series plots, but not desired if one is interested in accurate probability density functions. For more details about the difference between StochPy solvers and these fixed-interval solvers see http://www.plosone.org/article/info%3Adoi%2F10.1371%2Fjournal.pone.0079345.
In [1]:
"""
Written by TR Maarleveld, Amsterdam, The Netherlands
E-mail: [email protected]
Last Change:September 26 2014
"""

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

Info: Direct method is selected to perform stochastic simulations.
Parsing file: /home/timo/Stochpy/pscmodels/ImmigrationDeath.psc
Info: No reagents have been fixed

#######################################################################
#                                                                     #
#            Welcome to the interactive StochPy environment           #
#                                                                     #
#######################################################################
#  StochPy: Stochastic modeling in Python                             #
#  http://stochpy.sourceforge.net                                     #
#  Copyright(C) T.R Maarleveld, B.G. Olivier, F.J Bruggeman 2010-2014 #
#  DOI: 10.1371/journal.pone.0079345                                  #
#  Email: [email protected]                                #
#  VU University, Amsterdam, Netherlands                              #
#  Centrum Wiskunde Informatica, Amsterdam, Netherlands               #
#######################################################################

Version 2.2.0
Output Directory: /home/timo/Stochpy
Model Directory: /home/timo/Stochpy/pscmodels
Warning: Figure freezing? Try a different matplotlib backend (stochpy.plt.switch_backend) and/or set IsInteractive to False (see user guide)
Info: Direct method is selected to perform stochastic simulations.
Parsing file: /home/timo/Stochpy/pscmodels/ImmigrationDeath.psc
Info: No reagents have been fixed


### Using CAIN solvers in StochPy¶

Cain SSAs can be used if they are installed correctly (InterfaceCain). Note that these solvers have severe limitations, but can result in a significant speed-up.
In [3]:
smod.DoCainStochSim(IsTrackPropensities=1)
smod.PlotSpeciesTimeSeries()
smod.PlotPropensitiesTimeSeries()
smod.PrintSpeciesMeans()
smod.PrintSpeciesStandardDeviations()

Warning: Only mass-action kinetics can be correctly parsed by the Cain solvers
Warning: Do not use net stoichiometric coefficients for fixed-interval output solvers. Use X > {2} in stead of $pool > X Info: 1 trajectory is generated until t = 100 with 10000 frames Info: Simulation time 0.035 Info: Parsing data to StochPy and calculating propensities and distributions ... Info: Data successfully parsed into StochPy Species Mean mRNA 49.510000 Species Standard Deviation mRNA 5.559667  ### Using StochKit solvers in StochPy¶ StochKit 2 SSAs can be used if they are installed correctly (InterfaceStochkit). Note that these solvers can result in a significant speed-up, whereas they do have some disadvantages (e.g. waiting times cannot be calculated). In [4]: # Use StochKit SSAs, if installed correctly (InterfaceStochKit) smod.DoStochKitStochSim(IsTrackPropensities=1,frames=1000) smod.PlotSpeciesTimeSeries() smod.PlotPropensitiesTimeSeries() smod.PrintSpeciesMeans() smod.PrintSpeciesStandardDeviations()  Warning: Do not use net stoichiometric coefficients for fixed-interval output solvers. Use X > {2} in stead of$pool > X
Info: 1 trajectory is generated until t = 100 with 1000 frames
Info: Simulation time including compiling 0.088
Info: Parsing data to StochPy and calculating propensities and distributions ...
Info: Data successfully parsed into StochPy
Species	Mean
mRNA	49.070000
Species	Standard Deviation
mRNA	7.439429