Stochastic Simulations with StochKit2

From bio-physics-wiki

Revision as of 14:53, 15 August 2016 by Andreas Piehler (Talk | contribs)

Jump to: navigation, search

StochKit2
 provides 
command‐line
 executables 
for
 running 
stochastic
 simulations
 using
 variants 
of 
Gillespie’s 
Stochastic
 Simulation
 Algorithm
 and 
Tau‐leaping.




Installing Stochkit

(for Windows)

  1. Install Visual Studio: Download Visual Studio Community (free download link).
  2. Download StochKit2 form sourceforge and save it to the installation folder.
  3. Convert 
StochKit
 to 
match 
your
 version
 of 
Visual
Studio

    1. Open
 the 
StochKit2<version>_WINDOWS
 folder


    2. Double 
click
 ‘StochKit.sln’ 
or
 right
 click 
the 
icon
 and 
open
 with
 Visual 
Studio ,
which
 will
 load
 Stoch Kit
 into 
Visual 
Studio. 
Visual 
Studio
 will 
convert 
the 
Stoch Kit
project 
to 
your
 version. 

After
 the 
project
 is
 converted,
 close 
Visual 
Studio.

    3. Open 
Mixed_Compiled_Solution\Mixed_Compiled_Solution.sln 
in 
Visual
 Studio 
by
 double‐clicking
 to 
convert 
to 
your 
Visual 
Studio
 version. 
After
 the
 project
 is
 converted,
 close 
Visual
 Studio.

  4. Build
StochKit

    1. Open
 the
 Visual 
Studio
 Command 
Prompt 
(Start ‐> All
Programs ‐> Microsoft
Visual
Studio
2010
Express ‐> Visual
Studio
Command
Prompt
(2010)).

    2. Run
Installation.bat
 (you
 can
 just 
drag 
the 
file 
into
 the 
Visual
 Studio
 Command
 Prompt
 and
 click
 enter 
or
 ‘cd’
 to 
the 
Stoch Kit 
directory
 and
 type
 ‘Installation.bat’ 
and 
enter).

    3. Wait 
while
 StochKit
 is
 installed.


(for MacOS)

  1. Download StochKit2 form sourceforge and save it to the installation folder.
  2. cd to the installation folder and execute install.sh
  3. Add stochkit to your system path. In the termianal type:
sudo nano /etc/paths
add the location of the installation folder and the /bin subdirectory to the directory list
  1. you can use the terminal to execute ./ssa commands (no need for visual studio)

Creating a Model

You can use Sencillo a Python version of Facile to create an .xml model-file from a text-file.

  1. Create a .eqn (equation) file with a text editor and save it to you Stochkit folder (e.g. C:\StochSim\Model.eqn). The file should contain the parameters, reactions and initial conditions of your model for example;
  2. parameter kon = 28.82326214225031
    parameter koff = 15.9527830278967
    parameter v = 250.6026048853528
    parameter d = 1
    parameter prod = 2
    parameter deg = 1
    D_off -> D_on; kon
    D_on -> D_off; koff
    D_on -> D_on + M; v
    M -> null; d
    M -> M + P; prod
    P -> null; deg
    D_off = 1
    D_on = 0
    M = 2
    P=0
    
  3. Make sure you installed Python and added the Python-folder to your system path (Windows: go to explorer: control panel > system and security > system; click advanced settings; click "environmental variables"; scroll to variable "Path" and add your sencillo folder path to the "value" area after a semicolon e.g. ...;C:\Python27\ Mac: install python using e.g. the brew package manager brew install python ).
  4. Download Sencillo [here]. In Windows if you save it to the same folder as Stochkit (e.g. C:\StochSim) it will also be on the $PATH and available in the virtual studio terminal. Python is on the system path when it was installed on Mac using brew. Navigate to the installation folder using the terminal or add the sencillo python module by typing in the terminal
  5. python /path/to/stochkit/install/folder/sencillo.py install 
    
  6. Simply run the command:
  7. sencillo.py -s Model.eqn
    

    to generate the Model.xml file (it will be saved as C:\StochSim\Model.xml)

  8. Use Model.xml as input for Stochkit

Run Gillespie Simulation

  1. Open the Visual Studio terminal and navigate to your Stochkit folder
  2. run the command:
  3. .\ssa -m models\examples\dimer_decay.xml -t 10 -r 100 -i 10 --keep-trajectories -f 
    
    • "-m directory" tells the driver where in the Stochkit folder your xml-model is
    • "-r 100" means 
10
0 realizations 
of
 the 
model are computed
    • "-t 10" means the whole simulation time will be split into 10 time intervals.


    Optional inputs:
    • "-i 5"
 indicates 
that 
data
 should 
be 
kept
 at 
5
 evenly‐spaced 
time
 intervals.

 In
 this
 example,
 data
 will
 be 
stored 
at 
time
points 
0,
2,
4,
6,
8, 
and
 10. 

NOTE: 
data
 is 
stored 
at
 6 
time
points 
when
 the
 number 
of 
intervals
 is 
5.

 When 
0
 is 
chosen,
 data 
is 
kept
 only
 at
 the
 end
time.

    • "--keep-trajectories" tells 
the 
driver 
to 
keep 
trajectory
 data. 

This
 will
 create 
an
 output
directory
 named
 <output
directory>/trajectories 
that 
will
 contain
 one 
file 
for 
each 
realization. 

Use 
this
 option 
with
 caution 
since 
running
 a 
large 
number 
of 
realizations
 and 
keeping 
data
 at 
a
large 
number
 of
 intervals
 will
 lead
 to 
StochKit
 producing
 a
 large
 amount 
of
 output 
data.

    • "-f" 
short
 for
 "--force" 
specifies
 that 
we 
want 
to 
overwrite
 the 
existing
 output 
directory
 with 
our 
new
 data. 

If 
we
 had 
omitted
 this 
option, 
we
 would 
have
 received
 an
 error
message.
    keep in mind that for Windows you need to use backward slash "\" in the terminal, while for linux and mac you work woth forwardslash "/"