Skip to content

Commit

Permalink
Merge pull request #172 from GillesPy2/release_1_1_2
Browse files Browse the repository at this point in the history
Release 1 1 2
  • Loading branch information
briandrawert authored Jul 18, 2019
2 parents 346d96e + ba3fc69 commit 1bf2f1f
Show file tree
Hide file tree
Showing 54 changed files with 1,127 additions and 773 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ python: "3.6"
install:
- pip3 install .
- pip3 install python-libsbml
- pip3 install cython
script:
python test/run_tests.py -m release

10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Gillespy2
# GillesPy2


GillesPy2 is a python library designed to create stochastic simulations for biochemical systems. This package provides an object-oriented approach to creating mathematical models based on these real-world systems and simulates reaction events over time, selecting from a variety of algorithms including ODE solutions, the Gillespie Direct algorithm (SSA), and several variants of the SSA. This library contains multiple versions of solvers to support a variety of user environments with optimized code for C++, Cython, and NumPy.
Expand All @@ -7,6 +7,10 @@

https://docs.google.com/forms/d/12tAH4f8CJ-3F-lK44Q9uQHFio_mGoK0oY829q5lD7i4/viewform

![PyPI](https://img.shields.io/pypi/v/gillespy2.svg)
![PyPI - License](https://img.shields.io/pypi/l/gillespy2.svg?color=green)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/gillespy2.svg)


## Installation
You can install gillespy2 through the following methods.
Expand All @@ -32,7 +36,7 @@ GillesPy2 performs stochastic biochemical simulations utilizing simplified objec
2. call the model's '.run()' method.

The run method can be customized using keyword arguments to select different solvers, random seed, data return type and more.
For more detailed examples on how to use GillesPy2, please see the [Getting Started](/examples/Getting-Started.ipynb) notebook contained in the [examples](/examples) subdirectory.
For more detailed examples on how to use GillesPy2, please see the [Getting Started](https://github.com/GillesPy2/GillesPy2/tree/master/examples/Getting-Started.ipynb) notebook contained in the [examples](https://github.com/GillesPy2/GillesPy2/tree/master/examples) subdirectory.

## Built With

Expand All @@ -42,7 +46,7 @@ For more detailed examples on how to use GillesPy2, please see the [Getting Star

## Contributing

If you have any problems, or want to request a feature, please submit an issue to this repository. If you want to contribute to GillesPy2, please follow the guidelines set forth in [CONTRIBUTING.md](CONTRIBUTING.md). If you have any questions, contact Brian Drawert.
If you have any problems, or want to request a feature, please submit an issue to this repository. If you want to contribute to GillesPy2, please follow the guidelines set forth in [CONTRIBUTING.md](https://github.com/GillesPy2/GillesPy2/tree/master/CONTRIBUTING.md). If you have any questions, contact Brian Drawert.

## Authors

Expand Down
4 changes: 2 additions & 2 deletions coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/doctrees/gillespy2.core.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/gillespy2.solvers.numpy.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/setup.doctree
Binary file not shown.
51 changes: 32 additions & 19 deletions docs/build/html/_modules/gillespy2/core/gillespy2.html

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions docs/build/html/_modules/gillespy2/sbml/SBMLimport.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ <h1>Source code for gillespy2.sbml.SBMLimport</h1><div class="highlight"><pre>
<span class="k">continue</span>
<span class="n">name</span> <span class="o">=</span> <span class="n">species</span><span class="o">.</span><span class="n">getId</span><span class="p">()</span>
<span class="k">if</span> <span class="n">species</span><span class="o">.</span><span class="n">isSetInitialAmount</span><span class="p">():</span>
<span class="n">value</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">species</span><span class="o">.</span><span class="n">getInitialAmount</span><span class="p">())</span>
<span class="n">mode</span> <span class="o">=</span> <span class="s1">&#39;dynamic&#39;</span>
<span class="n">int_value</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">species</span><span class="o">.</span><span class="n">getInitialAmount</span><span class="p">())</span>
<span class="n">value</span> <span class="o">=</span> <span class="n">species</span><span class="o">.</span><span class="n">getInitialAmount</span><span class="p">()</span>
<span class="k">if</span> <span class="n">value</span> <span class="o">==</span> <span class="n">int_value</span><span class="p">:</span>
<span class="n">value</span> <span class="o">=</span> <span class="n">int_value</span>
<span class="n">mode</span> <span class="o">=</span> <span class="s1">&#39;dynamic&#39;</span>
<span class="k">else</span><span class="p">:</span> <span class="n">mode</span> <span class="o">=</span> <span class="s1">&#39;continuous&#39;</span>
<span class="k">elif</span> <span class="n">species</span><span class="o">.</span><span class="n">isSetInitialConcentration</span><span class="p">():</span>
<span class="n">value</span> <span class="o">=</span> <span class="n">species</span><span class="o">.</span><span class="n">getInitialConcentration</span><span class="p">()</span>
<span class="n">mode</span> <span class="o">=</span> <span class="s1">&#39;continuous&#39;</span>
Expand Down
21 changes: 15 additions & 6 deletions docs/build/html/_modules/gillespy2/solvers/cpp/ssa_c_solver.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ <h1>Source code for gillespy2.solvers.cpp.ssa_c_solver</h1><div class="highlight
<span class="n">outfile</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">&quot;};</span><span class="se">\n</span><span class="s2">unsigned int populations[] = {&quot;</span><span class="p">)</span>
<span class="c1">#Write initial populations.</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">species</span><span class="p">)</span><span class="o">-</span><span class="mi">1</span><span class="p">):</span>
<span class="n">outfile</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">{}</span><span class="s1">, &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">listOfSpecies</span><span class="p">[</span><span class="n">species</span><span class="p">[</span><span class="n">i</span><span class="p">]]</span><span class="o">.</span><span class="n">initial_value</span><span class="p">))</span>
<span class="n">outfile</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">listOfSpecies</span><span class="p">[</span><span class="n">species</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span><span class="o">.</span><span class="n">initial_value</span><span class="p">))</span>
<span class="n">outfile</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">{}</span><span class="s1">, &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">listOfSpecies</span><span class="p">[</span><span class="n">species</span><span class="p">[</span><span class="n">i</span><span class="p">]]</span><span class="o">.</span><span class="n">initial_value</span><span class="p">)))</span>
<span class="n">outfile</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">listOfSpecies</span><span class="p">[</span><span class="n">species</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span><span class="o">.</span><span class="n">initial_value</span><span class="p">)))</span>
<span class="n">outfile</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">&quot;};</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">reactions</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="c1">#Write reaction names</span>
Expand Down Expand Up @@ -204,7 +204,7 @@ <h1>Source code for gillespy2.solvers.cpp.ssa_c_solver</h1><div class="highlight
<span class="k">if</span> <span class="n">built</span><span class="o">.</span><span class="n">returncode</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">compiled</span> <span class="o">=</span> <span class="kc">True</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">gillespyError</span><span class="o">.</span><span class="n">BuildError</span><span class="p">(</span><span class="s2">&quot;Error encountered while compiling file:</span><span class="se">\n</span><span class="s2">Return code: </span><span class="si">{0}</span><span class="s2">.</span><span class="se">\n</span><span class="s2">Error:</span><span class="se">\n</span><span class="si">{1}</span><span class="se">\n</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">built</span><span class="o">.</span><span class="n">returncode</span><span class="p">,</span> <span class="n">built</span><span class="o">.</span><span class="n">stderr</span><span class="p">))</span></div>
<span class="k">raise</span> <span class="n">gillespyError</span><span class="o">.</span><span class="n">BuildError</span><span class="p">(</span><span class="s2">&quot;Error encountered while compiling file:</span><span class="se">\n</span><span class="s2">Return code: </span><span class="si">{0}</span><span class="s2">.</span><span class="se">\n</span><span class="s2">Error:</span><span class="se">\n</span><span class="si">{1}</span><span class="se">\n</span><span class="si">{2}</span><span class="se">\n</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">built</span><span class="o">.</span><span class="n">returncode</span><span class="p">,</span> <span class="n">built</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">),</span><span class="n">built</span><span class="o">.</span><span class="n">stderr</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)))</span></div>

<div class="viewcode-block" id="SSACSolver.run"><a class="viewcode-back" href="../../../../gillespy2.solvers.cpp.html#gillespy2.solvers.auto.ssa_solver.SSACSolver.run">[docs]</a> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">model</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">t</span><span class="o">=</span><span class="mi">20</span><span class="p">,</span> <span class="n">number_of_trajectories</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
<span class="n">increment</span><span class="o">=</span><span class="mf">0.05</span><span class="p">,</span> <span class="n">seed</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">debug</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">profile</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">show_labels</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
Expand All @@ -215,9 +215,18 @@ <h1>Source code for gillespy2.solvers.cpp.ssa_c_solver</h1><div class="highlight
<span class="n">number_timesteps</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">t</span><span class="o">//</span><span class="n">increment</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="c1"># Execute simulation.</span>
<span class="n">args</span> <span class="o">=</span> <span class="p">[</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">output_directory</span><span class="p">,</span> <span class="s1">&#39;UserSimulation&#39;</span><span class="p">),</span> <span class="s1">&#39;-trajectories&#39;</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">number_of_trajectories</span><span class="p">),</span> <span class="s1">&#39;-timesteps&#39;</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">number_timesteps</span><span class="p">),</span> <span class="s1">&#39;-end&#39;</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">t</span><span class="p">)]</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">seed</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
<span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;-seed&#39;</span><span class="p">)</span>
<span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">seed</span><span class="p">))</span>
<span class="k">if</span> <span class="n">seed</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">seed</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
<span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;-seed&#39;</span><span class="p">)</span>
<span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">seed</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">seed_int</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">seed</span><span class="p">)</span>
<span class="k">if</span> <span class="n">seed_int</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;-seed&#39;</span><span class="p">)</span>
<span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">seed_int</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">ModelError</span><span class="p">(</span><span class="s2">&quot;seed must be a positive integer&quot;</span><span class="p">)</span>

<span class="n">simulation</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">stderr</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">)</span>
<span class="c1"># Parse/return results.</span>
<span class="k">if</span> <span class="n">simulation</span><span class="o">.</span><span class="n">returncode</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
Expand Down
Loading

0 comments on commit 1bf2f1f

Please sign in to comment.