Stochastic Simulations with StochKit2
From bio-physics-wiki
(Difference between revisions)
(→Creating a Model) |
(→Creating a Model) |
||
Line 49: | Line 49: | ||
</li> | </li> | ||
<li> Download Sencillo [[http://swainlab.bio.ed.ac.uk/software/sencillo/ here]] and save it to the same folder as Stochkit (e.g. C:\StochSim). Navigate to the installation folder using the terminal or add the sencillo python module. Type in the terminal | <li> Download Sencillo [[http://swainlab.bio.ed.ac.uk/software/sencillo/ here]] and save it to the same folder as Stochkit (e.g. C:\StochSim). Navigate to the installation folder using the terminal or add the sencillo python module. Type in the terminal | ||
+ | |||
python /path/to/stochkit/install/folder/sencillo.py install | python /path/to/stochkit/install/folder/sencillo.py install | ||
+ | |||
</li> | </li> | ||
<li> Simply run the command: </li> | <li> Simply run the command: </li> |
Revision as of 14:48, 15 August 2016
StochKit2 provides command‐line executables for running stochastic simulations using variants of Gillespie’s Stochastic Simulation Algorithm and Tau‐leaping.
Installing Stochkit
(for Windows)
- Install Visual Studio: Download Visual Studio Community (free download link).
- Download StochKit2 form sourceforge and save it to the installation folder.
- Convert
StochKit
to
match
your
version
of
Visual
Studio
- Open the StochKit2<version>_WINDOWS folder
- 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.
- 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.
- Build
StochKit
- Open the Visual Studio Command Prompt (Start ‐> All Programs ‐> Microsoft Visual Studio 2010 Express ‐> Visual Studio Command Prompt (2010)).
- 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).
- Wait while StochKit is installed.
(for MacOS)
- Download StochKit2 form sourceforge and save it to the installation folder.
- cd to the installation folder and execute install.sh
- 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
- 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.
- 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;
- 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 ).
- Download Sencillo [here] and save it to the same folder as Stochkit (e.g. C:\StochSim). Navigate to the installation folder using the terminal or add the sencillo python module. Type in the terminal python /path/to/stochkit/install/folder/sencillo.py install
- Simply run the command:
- Use Model.xml as input for Stochkit
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
sencillo.py -s Model.eqn
to generate the Model.xml file (it will be saved as C:\StochSim\Model.xml)
Run Gillespie Simulation
- Open the Visual Studio terminal and navigate to your Stochkit folder
- run the command:
- "-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.
.\ssa -m models\examples\dimer_decay.xml -t 10 -r 100 -i 10 --keep-trajectories -f
keep in mind that for Windows you need to use backward slash "\" in the terminal, while for linux and mac you work woth forwardslash "/"