Skip to content

Commit

Permalink
Merge pull request #789 from StochSS/develop
Browse files Browse the repository at this point in the history
Release v1.7.0
  • Loading branch information
seanebum authored Aug 10, 2022
2 parents 6098954 + 8f88dda commit a41786a
Show file tree
Hide file tree
Showing 270 changed files with 46,371 additions and 40,680 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/run-full-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ jobs:
with:
python-version: ${{ matrix.python-versions }}

# see: https://github.com/actions/virtual-environments/pull/5729
# GHA recently upgrading MinGW to v11.20, which seems to break things in that environment.
# Until this issue can be addressed, downgrade to the previous known working version, v8.1.0.
- name: Initialize MinGW dependencies
run: |
choco install make
choco uninstall mingw
choco install mingw --version 8.1.0 --force
if: matrix.os == 'windows-latest'

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -32,4 +42,4 @@ jobs:
pip install nbformat
- name: Run tests
run: coverage run --source=gillespy2 --omit=gillespy2/solvers/stochkit/* test/run_tests.py -m develop
run: coverage run --source=gillespy2 --omit=gillespy2/solvers/stochkit/* test/run_integration_tests.py -m develop
42 changes: 42 additions & 0 deletions .github/workflows/run-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Run GillesPy2 Integration Tests

on: [push]

jobs:
run-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]

steps:
- name: Initialize environment
uses: actions/checkout@v2

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.7'

# see: https://github.com/actions/virtual-environments/pull/5729
# GHA recently upgrading MinGW to v11.20, which seems to break things in that environment.
# Until this issue can be addressed, downgrade to the previous known working version, v8.1.0.
- name: Initialize MinGW dependencies
run: |
choco install make
choco uninstall mingw
choco install mingw --version 8.1.0 --force
if: matrix.os == 'windows-latest'

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install python-libsbml
pip install cython
pip install coverage
pip install nbformat
pip install nbconvert
- name: Run tests
run: coverage run --source=gillespy2 --omit=gillespy2/solvers/stochkit/* test/run_integration_tests.py -m develop
44 changes: 44 additions & 0 deletions .github/workflows/run-system-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Run GillesPy2 System Tests

on:
push:
branches: [main, develop]

jobs:
run-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]

steps:
- name: Initialize environment
uses: actions/checkout@v2

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.7'

# see: https://github.com/actions/virtual-environments/pull/5729
# GHA recently upgrading MinGW to v11.20, which seems to break things in that environment.
# Until this issue can be addressed, downgrade to the previous known working version, v8.1.0.
- name: Initialize MinGW dependencies
run: |
choco install make
choco uninstall mingw
choco install mingw --version 8.1.0 --force
if: matrix.os == 'windows-latest'

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install python-libsbml
pip install cython
pip install coverage
pip install nbformat
pip install nbconvert
- name: Run tests
run: coverage run --source=gillespy2 --omit=gillespy2/solvers/stochkit/* test/run_system_tests.py -m develop
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run GillesPy2 Tests
name: Run GillesPy2 Unit Tests

on: [push]

Expand All @@ -18,6 +18,16 @@ jobs:
with:
python-version: '3.7'

# see: https://github.com/actions/virtual-environments/pull/5729
# GHA recently upgrading MinGW to v11.20, which seems to break things in that environment.
# Until this issue can be addressed, downgrade to the previous known working version, v8.1.0.
- name: Initialize MinGW dependencies
run: |
choco install make
choco uninstall mingw
choco install mingw --version 8.1.0 --force
if: matrix.os == 'windows-latest'

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -29,4 +39,4 @@ jobs:
pip install nbconvert
- name: Run tests
run: coverage run --source=gillespy2 --omit=gillespy2/solvers/stochkit/* test/run_tests.py -m develop
run: coverage run --source=gillespy2 --omit=gillespy2/solvers/stochkit/* test/run_unit_tests.py -m develop
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ __pycache__
.coverage
htmlcov
/build
.idea

3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ install:
- pip3 install cython
- pip3 install coverage
script:
- "coverage run --source=gillespy2 --omit=gillespy2/solvers/stochkit/* test/run_tests.py -m develop"
- "coverage run --source=gillespy2 --omit=gillespy2/solvers/stochkit/* test/run_unit_tests.py -m develop"
- "coverage run --source=gillespy2 --omit=gillespy2/solvers/stochkit/* test/run_integration_tests.py -m develop"
deploy:
# API token stored in env var PYPI_PASSWORD on Travis CI
provider: pypi
Expand Down
61 changes: 31 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="https://raw.githubusercontent.com/StochSS/GillesPy2/develop/.graphics/gillespy2-logo.png">
</p>

GillesPy2 is a Python 3 package for stochastic simulation of biochemical systems. It offers an object-oriented approach for creating mathematical models of biological systems, as well as a variety of methods for performing time simulation of those models. The methods include the [Gillespie direct method (SSA)](https://en.wikipedia.org/wiki/Gillespie_algorithm), several variant stochastic simulation methods including [tau-leaping](https://en.wikipedia.org/wiki/Tau-leaping), and numerical integration of ODEs. The solvers support a variety of user environments, with optimized code for C++, [Cython](https://cython.org), and [NumPy](https://numpy.org). GillesPy2 also supports [SBML](https://en.wikipedia.org/wiki/SBML).
GillesPy2 is a Python 3 package for stochastic simulation of biochemical systems. It offers an object-oriented approach for creating mathematical models of biological systems, as well as a variety of methods for performing time simulation of those models. The methods include the [Gillespie direct method (SSA)](https://en.wikipedia.org/wiki/Gillespie_algorithm), several variant stochastic simulation methods including [tau-Leaping](https://en.wikipedia.org/wiki/Tau-leaping), and numerical integration of ODEs. The solvers support a variety of user environments, with optimized code for C++, [Cython](https://cython.org), and [NumPy](https://numpy.org). GillesPy2 also supports [SBML](https://en.wikipedia.org/wiki/SBML).

<table><tr><td><b>
<img width="20%" align="right" src="https://raw.githubusercontent.com/StochSS/GillesPy2/develop/.graphics/stochss-logo.png">
Expand Down Expand Up @@ -70,7 +70,7 @@ GillesPy2 provides simple object-oriented abstractions for defining a model of a
1. Create a `GillesPy2.Model` containing molecular species, parameters, and reactions (or import it from an [SBML](http://sbml.org) file)
2. Invoke 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](https://github.com/StochSS/GillesPy2/tree/main/examples/StartHere.ipynb) Jupyter notebook contained in the [examples](https://github.com/StochSS/GillesPy2/tree/main/examples) subdirectory.
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](https://github.com/StochSS/GillesPy2/tree/main/examples/Start_Here.ipynb) Jupyter notebook contained in the [examples](https://github.com/StochSS/GillesPy2/tree/main/examples) subdirectory.

### _Simple example to illustrate the use of GillesPy2_

Expand All @@ -82,43 +82,44 @@ The `run()` method can be customized using keyword arguments to select different
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>k<sub>d</sub></i><br>
</p>

In GillesPy2, a model is expressed as an object having the parent class `Model`. Components of the model, such as the reactions, molecular species, and characteristics such as the time span for simulation, are all defined within the subclass definition. The following Python code represents our dimerization model using GillesPy2's facility:
In GillesPy2, a model is expressed as an object. Components, such as the reactions, molecular species, and characteristics such as the time span for simulation, are all defined within the model. The following Python code represents our dimerization model using GillesPy2's facility:

```python
class Dimerization(gillespy2.Model):
def __init__(self, parameter_values=None):
# First call the gillespy2.Model initializer.
gillespy2.Model.__init__(self, name='Dimerization')

# Define parameters for the rates of creation and dissociation.
k_c = gillespy2.Parameter(name='k_c', expression=0.005)
k_d = gillespy2.Parameter(name='k_d', expression=0.08)
self.add_parameter([k_c, k_d])

# Define variables for the molecular species representing M and D.
m = gillespy2.Species(name='monomer', initial_value=30)
d = gillespy2.Species(name='dimer', initial_value=0)
self.add_species([m, d])

# The list of reactants and products for a Reaction object are each a
# Python dictionary in which the dictionary keys are Species objects
# and the values are stoichiometries of the species in the reaction.
r_c = gillespy2.Reaction(name="r_creation", rate=k_c, reactants={m:2}, products={d:1})
r_d = gillespy2.Reaction(name="r_dissociation", rate=k_d, reactants={d:1}, products={m:2})
self.add_reaction([r_c, r_d])

# Set the timespan for the simulation.
self.timespan(numpy.linspace(0, 100, 101))
def create_dimerization(parameter_values=None):
# First call the gillespy2.Model initializer.
model = gillespy2.model(name='Dimerization')

# Define parameters for the rates of creation and dissociation.
k_c = gillespy2.Parameter(name='k_c', expression=0.005)
k_d = gillespy2.Parameter(name='k_d', expression=0.08)
model.add_parameter([k_c, k_d])

# Define variables for the molecular species representing M and D.
m = gillespy2.Species(name='monomer', initial_value=30)
d = gillespy2.Species(name='dimer', initial_value=0)
model.add_species([m, d])

# The list of reactants and products for a Reaction object are each a
# Python dictionary in which the dictionary keys are Species objects
# and the values are stoichiometries of the species in the reaction.
r_c = gillespy2.Reaction(name="r_creation", rate=k_c, reactants={m:2}, products={d:1})
r_d = gillespy2.Reaction(name="r_dissociation", rate=k_d, reactants={d:1}, products={m:2})
model.add_reaction([r_c, r_d])

# Set the timespan for the simulation.
tspan = gillespy2.TimeSpan.linspace(t=100, num_points=101)
model.timespan(tspan)
return model
```

Given the class definition above, the model can be simulated by first instantiating the class object, and then invoking the `run()` method on the object. The following code will run the model 10 times to produce 10 sample trajectories:
Given the model creation function above, the model can be simulated by first instantiating the model object, and then invoking the run() method on the object. The following code will run the model 10 times to produce 10 sample trajectories:

```python
model = Dimerization()
model = create_dimerization()
results = model.run(number_of_trajectories=10)
```

The results are then stored in a class `Results` object for single trajectories, or a class `Ensemble` object for multiple trajectories. Results/Ensembles can be plotted with matplotlib using `plot()` or in plotly (offline) using `plotplotly()`. For additional plotting options such as plotting from a selection of species, or statistical plotting, please see the documentation.:
The results are then stored in a class `Results` object for single trajectory or for multiple trajectories. Results can be plotted with matplotlib using `plot()` or in plotly (offline) using `plotplotly()`. For additional plotting options such as plotting from a selection of species, or statistical plotting, please see the documentation.:

```python
results.plot()
Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 3660d62a689826af0ef6e8b2cfa373ce
config: b55ff5dc6e7452417ea83baca6ee686c
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file modified docs/build/html/.doctrees/classes/gillespy2.core.doctree
Binary file not shown.
Binary file modified docs/build/html/.doctrees/classes/gillespy2.doctree
Binary file not shown.
Binary file modified docs/build/html/.doctrees/classes/gillespy2.sbml.doctree
Binary file not shown.
Binary file modified docs/build/html/.doctrees/classes/gillespy2.solvers.auto.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/build/html/.doctrees/classes/gillespy2.solvers.cython.doctree
Binary file not shown.
Binary file modified docs/build/html/.doctrees/classes/gillespy2.solvers.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/build/html/.doctrees/classes/gillespy2.stochss.doctree
Binary file not shown.
Binary file modified docs/build/html/.doctrees/environment.pickle
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/build/html/.doctrees/index.doctree
Binary file not shown.
Binary file not shown.
Binary file modified docs/build/html/.doctrees/tutorials/tut_sbml/tut_sbml.doctree
Binary file not shown.
Binary file not shown.
5 changes: 3 additions & 2 deletions docs/build/html/_modules/gillespy2/core/assignmentrule.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>gillespy2.core.assignmentrule &#8212; GillesPy2 1.6.9 documentation</title>
<title>gillespy2.core.assignmentrule &#8212; GillesPy2 1.6.10 documentation</title>
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../../../_static/alabaster.css" />
<link rel="stylesheet" type="text/css" href="../../../_static/css/gillespy2_alabaster_customizations.css" />
Expand Down Expand Up @@ -146,7 +146,8 @@ <h1>Source code for gillespy2.core.assignmentrule</h1><div class="highlight"><pr
<span class="bp">self</span><span class="o">.</span><span class="n">formula</span> <span class="o">=</span> <span class="n">formula</span>

<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">variable</span> <span class="o">+</span> <span class="s1">&#39;: &#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">formula</span>
<span class="n">var_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">variable</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">variable</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">variable</span><span class="o">.</span><span class="n">name</span>
<span class="k">return</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">: Var: </span><span class="si">{</span><span class="n">var_name</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">formula</span><span class="si">}</span><span class="s2">&quot;</span>

<div class="viewcode-block" id="AssignmentRule.sanitized_formula"><a class="viewcode-back" href="../../../classes/gillespy2.core.html#gillespy2.core.assignmentrule.AssignmentRule.sanitized_formula">[docs]</a> <span class="k">def</span> <span class="nf">sanitized_formula</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">species_mappings</span><span class="p">,</span> <span class="n">parameter_mappings</span><span class="p">):</span>
<span class="n">names</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">species_mappings</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> <span class="o">+</span> <span class="nb">list</span><span class="p">(</span><span class="n">parameter_mappings</span><span class="o">.</span><span class="n">keys</span><span class="p">()),</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">),</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/_modules/gillespy2/core/cleanup.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>gillespy2.core.cleanup &#8212; GillesPy2 1.6.9 documentation</title>
<title>gillespy2.core.cleanup &#8212; GillesPy2 1.6.10 documentation</title>
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../../../_static/alabaster.css" />
<link rel="stylesheet" type="text/css" href="../../../_static/css/gillespy2_alabaster_customizations.css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/_modules/gillespy2/core/events.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>gillespy2.core.events &#8212; GillesPy2 1.6.9 documentation</title>
<title>gillespy2.core.events &#8212; GillesPy2 1.6.10 documentation</title>
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../../../_static/alabaster.css" />
<link rel="stylesheet" type="text/css" href="../../../_static/css/gillespy2_alabaster_customizations.css" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>gillespy2.core.functiondefinition &#8212; GillesPy2 1.6.9 documentation</title>
<title>gillespy2.core.functiondefinition &#8212; GillesPy2 1.6.10 documentation</title>
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../../../_static/alabaster.css" />
<link rel="stylesheet" type="text/css" href="../../../_static/css/gillespy2_alabaster_customizations.css" />
Expand Down
Loading

0 comments on commit a41786a

Please sign in to comment.