From 9011a61e1d043a0da3071974cbd69fc1fac36817 Mon Sep 17 00:00:00 2001 From: BryanRumsey <44621966+BryanRumsey@users.noreply.github.com> Date: Fri, 3 Mar 2023 11:13:08 -0500 Subject: [PATCH 01/11] Updated version to v2.5.1 --- __version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__version__.py b/__version__.py index d3476703d..445149aff 100644 --- a/__version__.py +++ b/__version__.py @@ -5,7 +5,7 @@ # @website https://github.com/stochss/stochss # ============================================================================= -__version__ = '2.5.0' +__version__ = '2.5.1' __title__ = 'StochSS' __description__ = 'StochSS is an integrated development environment (IDE) \ for simulation of biochemical networks.' From 5f632160e34f0df886dc8870b6870d76b0d0a128 Mon Sep 17 00:00:00 2001 From: BryanRumsey <44621966+BryanRumsey@users.noreply.github.com> Date: Tue, 7 Mar 2023 15:15:59 -0500 Subject: [PATCH 02/11] Update Dockerfile.jupyterhub --- jupyterhub/Dockerfile.jupyterhub | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jupyterhub/Dockerfile.jupyterhub b/jupyterhub/Dockerfile.jupyterhub index fd28f2482..538802cae 100644 --- a/jupyterhub/Dockerfile.jupyterhub +++ b/jupyterhub/Dockerfile.jupyterhub @@ -46,8 +46,8 @@ RUN python3 -m pip install --no-cache-dir \ psycopg2-binary==2.9.* \ nbviewer==1.0.1 \ notebook \ - gillespy2==1.7.2 \ - spatialpy==1.1.2 \ + gillespy2==1.8.1 \ + spatialpy==1.2.1 \ plotly # build the PUG pages From 13e455cafabe3ea3a9dd76a202fd9673f6ae24d2 Mon Sep 17 00:00:00 2001 From: BryanRumsey <44621966+BryanRumsey@users.noreply.github.com> Date: Tue, 7 Mar 2023 15:16:19 -0500 Subject: [PATCH 03/11] Update Dockerfile.jupyterhub --- jupyterhub/Dockerfile.jupyterhub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jupyterhub/Dockerfile.jupyterhub b/jupyterhub/Dockerfile.jupyterhub index 538802cae..d959eaaea 100644 --- a/jupyterhub/Dockerfile.jupyterhub +++ b/jupyterhub/Dockerfile.jupyterhub @@ -40,7 +40,7 @@ EXPOSE 8000 # Install dockerspawner, oauth, postgres RUN python3 -m pip install --no-cache-dir \ - jupyterhub \ + jupyterhub==3.1.1 \ oauthenticator==0.11.* \ dockerspawner==0.11.* \ psycopg2-binary==2.9.* \ From dd041d8994fa29756a86d6f0da1eae94f5a66d58 Mon Sep 17 00:00:00 2001 From: BryanRumsey <44621966+BryanRumsey@users.noreply.github.com> Date: Tue, 7 Mar 2023 15:16:55 -0500 Subject: [PATCH 04/11] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 2488d8957..671f6e35f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ python-libsedml==2.0.9 python-libcombine==0.2.7 pyabc==0.12.6 escapism==1.0.1 -gillespy2==1.8.0 +gillespy2==1.8.1 spatialpy==1.2.1 stochss-compute[AWS]==1.0.1 git+https://github.com/StochSS/sciope.git@master From 964ca486f3ba4e887fbe17a6b80abe61efa69dcd Mon Sep 17 00:00:00 2001 From: Brian Drawert Date: Wed, 8 Mar 2023 10:56:32 -0800 Subject: [PATCH 05/11] disable Oregonator and Brusselator --- stochss/tests/test_gillespy2.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/stochss/tests/test_gillespy2.py b/stochss/tests/test_gillespy2.py index 974159551..54e919006 100644 --- a/stochss/tests/test_gillespy2.py +++ b/stochss/tests/test_gillespy2.py @@ -22,7 +22,7 @@ from gillespy2 import GillesPySolver from example_models import ( - Brusselator, + #Brusselator, Degradation, Dimerization, LotkavolterraOscillator, @@ -31,7 +31,7 @@ Schlogl, ToggleSwitch, VilarOscillator, - Oregonator, + #Oregonator, TysonOscillator ) @@ -46,7 +46,8 @@ class TestGillesPy2Dependency(unittest.TestCase): ''' def setUp(self): ''' Create a list of common example paths for each test. ''' - self.test_models = [Brusselator, Degradation, Dimerization, LotkavolterraOscillator, + self.test_models = [#Brusselator, + Degradation, Dimerization, LotkavolterraOscillator, MichaelisMenten, Opioid, Schlogl, ToggleSwitch, VilarOscillator] ################################################################################################ @@ -90,7 +91,7 @@ def test_ode_solver(self): ''' Check if the test_models run with the ODESolver. ''' from gillespy2 import ODESolver - self.test_models.append(Oregonator) + #self.test_models.append(Oregonator) for model in self.test_models: test_model = model() with self.subTest(model=test_model.name): @@ -101,7 +102,7 @@ def test_ode_c_solver(self): ''' Check if the test_models run with the ODECSolver. ''' from gillespy2 import ODECSolver - self.test_models.append(Oregonator) + #self.test_models.append(Oregonator) for model in self.test_models: test_model = model() with self.subTest(model=test_model.name): @@ -159,7 +160,7 @@ def test_tau_hybrid_solver(self): ''' Check if the test_models run with the TauHybridSolver. ''' from gillespy2 import TauHybridSolver - self.test_models.append(Oregonator) + #self.test_models.append(Oregonator) self.test_models.append(TysonOscillator) self.test_models.remove(VilarOscillator) for model in self.test_models: @@ -172,7 +173,7 @@ def test_tau_hybrid_c_solver(self): ''' Check if the test_models run with the TauHybridCSolver. ''' from gillespy2 import TauHybridCSolver - self.test_models.append(Oregonator) + #self.test_models.append(Oregonator) self.test_models.append(TysonOscillator) self.test_models.remove(VilarOscillator) self.test_models.remove(ToggleSwitch) From cc0236aa7c43e4260db5bce427c3cedd4392f729 Mon Sep 17 00:00:00 2001 From: Bryan Rumsey Date: Wed, 8 Mar 2023 16:30:22 -0500 Subject: [PATCH 06/11] Split the test suite into unit tests and integration tests. --- .github/workflows/main.yml | 6 +-- Makefile | 2 +- stochss/tests/__init__.py | 0 stochss/tests/integration_tests/__init__.py | 0 .../{ => integration_tests}/test_gillespy2.py | 0 stochss/tests/run_all_tests.py | 38 +++++++++++++ stochss/tests/run_integration_tests.py | 54 +++++++++++++++++++ .../tests/{run_tests.py => run_unit_tests.py} | 43 +++++++-------- stochss/tests/unit_tests/__init__.py | 0 .../{ => unit_tests}/test_model_template.py | 0 .../test_settings_template.py | 0 .../{ => unit_tests}/test_stochss_base.py | 0 .../{ => unit_tests}/test_stochss_file.py | 0 13 files changed, 118 insertions(+), 25 deletions(-) create mode 100644 stochss/tests/__init__.py create mode 100644 stochss/tests/integration_tests/__init__.py rename stochss/tests/{ => integration_tests}/test_gillespy2.py (100%) create mode 100755 stochss/tests/run_all_tests.py create mode 100755 stochss/tests/run_integration_tests.py rename stochss/tests/{run_tests.py => run_unit_tests.py} (73%) create mode 100644 stochss/tests/unit_tests/__init__.py rename stochss/tests/{ => unit_tests}/test_model_template.py (100%) rename stochss/tests/{ => unit_tests}/test_settings_template.py (100%) rename stochss/tests/{ => unit_tests}/test_stochss_base.py (100%) rename stochss/tests/{ => unit_tests}/test_stochss_file.py (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 551a37799..d518d499a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,8 +10,8 @@ jobs: id: checkout uses: actions/checkout@v2.1.0 # Setup container & execute Python unit tests - - name: run_tests.py - id: run_tests + - name: run_all_tests.py + id: run_all_tests uses: ./ with: - testin: '/stochss/stochss/tests/run_tests.py' + testin: '/stochss/stochss/tests/run_all_tests.py' diff --git a/Makefile b/Makefile index a4f706ddc..3df4c9433 100644 --- a/Makefile +++ b/Makefile @@ -148,7 +148,7 @@ test: create_working_dir -v $(DOCKER_WORKING_DIR):/home/jovyan/ \ -p 8888:8888 \ $(DOCKER_STOCHSS_IMAGE):latest \ - /stochss/stochss/tests/run_tests.py + /stochss/stochss/tests/run_all_tests.py build_and_test: build test diff --git a/stochss/tests/__init__.py b/stochss/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/stochss/tests/integration_tests/__init__.py b/stochss/tests/integration_tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/stochss/tests/test_gillespy2.py b/stochss/tests/integration_tests/test_gillespy2.py similarity index 100% rename from stochss/tests/test_gillespy2.py rename to stochss/tests/integration_tests/test_gillespy2.py diff --git a/stochss/tests/run_all_tests.py b/stochss/tests/run_all_tests.py new file mode 100755 index 000000000..a4154ada7 --- /dev/null +++ b/stochss/tests/run_all_tests.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +''' +StochSS is a platform for simulating biochemical systems +Copyright (C) 2019-2023 StochSS developers. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +''' +import os +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument( + '-m', '--mode', default='staging', choices=['staging', 'release'], + help='Run tests in staging mode or release mode.' +) + +if __name__ == "__main__": + os.chdir('/stochss') + args = parser.parse_args() + print(os.path.dirname(__file__)) + + from run_unit_tests import run as run_unit + from run_integration_tests import run as run_integration + + run_unit(mode=args.mode) + run_integration(mode=args.mode) diff --git a/stochss/tests/run_integration_tests.py b/stochss/tests/run_integration_tests.py new file mode 100755 index 000000000..2e4989268 --- /dev/null +++ b/stochss/tests/run_integration_tests.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 + +''' +StochSS is a platform for simulating biochemical systems +Copyright (C) 2019-2023 StochSS developers. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +''' +import os +import sys +import unittest +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument( + '-m', '--mode', default='staging', choices=['staging', 'release'], + help='Run integration tests in staging mode or release mode.' +) + +def run(mode=None): + ''' Run the integration tests. ''' + from integration_tests import test_gillespy2 + + modules = [ + test_gillespy2 + ] + + for module in modules: + suite = unittest.TestLoader().loadTestsFromModule(module) + runner = unittest.TextTestRunner(failfast=mode == 'staging', verbosity=1) + + print("Executing: {}".format(module)) + result = runner.run(suite) + print('=' * 70) + if not result.wasSuccessful(): + sys.exit(not result.wasSuccessful()) + +if __name__ == "__main__": + os.chdir('/stochss') + args = parser.parse_args() + print(os.path.dirname(__file__)) + + run(mode=args.mode) diff --git a/stochss/tests/run_tests.py b/stochss/tests/run_unit_tests.py similarity index 73% rename from stochss/tests/run_tests.py rename to stochss/tests/run_unit_tests.py index b794f7c24..0187a4367 100755 --- a/stochss/tests/run_tests.py +++ b/stochss/tests/run_unit_tests.py @@ -17,43 +17,44 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . ''' - - - -import unittest -import sys import os +import sys +import unittest import argparse parser = argparse.ArgumentParser() -parser.add_argument('-m', '--mode', default='staging', choices=['staging', 'release'], - help='Run tests in staging mode or release mode.') - -if __name__ == "__main__": - os.chdir('/stochss') - args = parser.parse_args() - print(os.path.dirname(__file__)) - - import test_model_template - import test_settings_template - import test_stochss_base - import test_stochss_file - import test_gillespy2 - +parser.add_argument( + '-m', '--mode', default='staging', choices=['staging', 'release'], + help='Run unit tests in staging mode or release mode.' +) + +def run(mode=None): + ''' Run the unit tests. ''' + from unit_tests import test_model_template + from unit_tests import test_settings_template + from unit_tests import test_stochss_base + from unit_tests import test_stochss_file + modules = [ test_model_template, test_settings_template, - test_gillespy2, test_stochss_base, test_stochss_file ] for module in modules: suite = unittest.TestLoader().loadTestsFromModule(module) - runner = unittest.TextTestRunner(failfast=args.mode == 'staging', verbosity=1) + runner = unittest.TextTestRunner(failfast=mode == 'staging', verbosity=1) print("Executing: {}".format(module)) result = runner.run(suite) print('=' * 70) if not result.wasSuccessful(): sys.exit(not result.wasSuccessful()) + +if __name__ == "__main__": + os.chdir('/stochss') + args = parser.parse_args() + print(os.path.dirname(__file__)) + + run(mode=args.mode) diff --git a/stochss/tests/unit_tests/__init__.py b/stochss/tests/unit_tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/stochss/tests/test_model_template.py b/stochss/tests/unit_tests/test_model_template.py similarity index 100% rename from stochss/tests/test_model_template.py rename to stochss/tests/unit_tests/test_model_template.py diff --git a/stochss/tests/test_settings_template.py b/stochss/tests/unit_tests/test_settings_template.py similarity index 100% rename from stochss/tests/test_settings_template.py rename to stochss/tests/unit_tests/test_settings_template.py diff --git a/stochss/tests/test_stochss_base.py b/stochss/tests/unit_tests/test_stochss_base.py similarity index 100% rename from stochss/tests/test_stochss_base.py rename to stochss/tests/unit_tests/test_stochss_base.py diff --git a/stochss/tests/test_stochss_file.py b/stochss/tests/unit_tests/test_stochss_file.py similarity index 100% rename from stochss/tests/test_stochss_file.py rename to stochss/tests/unit_tests/test_stochss_file.py From 43024200cb4e88e2090bccb90cc0ac44667b973a Mon Sep 17 00:00:00 2001 From: Bryan Rumsey Date: Thu, 9 Mar 2023 09:28:40 -0500 Subject: [PATCH 07/11] Split the github actions for testing. --- .github/workflows/main.yml | 17 --------------- .github/workflows/run-integration-tests.yaml | 23 ++++++++++++++++++++ .github/workflows/run-unit-tests.yml | 21 ++++++++++++++++++ 3 files changed, 44 insertions(+), 17 deletions(-) delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/run-integration-tests.yaml create mode 100644 .github/workflows/run-unit-tests.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index d518d499a..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,17 +0,0 @@ -on: [push, pull_request] - -jobs: - run_tests: - runs-on: ubuntu-20.04 - name: StochSS Continuous Testing - steps: - # Checkout - - name: Checkout - id: checkout - uses: actions/checkout@v2.1.0 - # Setup container & execute Python unit tests - - name: run_all_tests.py - id: run_all_tests - uses: ./ - with: - testin: '/stochss/stochss/tests/run_all_tests.py' diff --git a/.github/workflows/run-integration-tests.yaml b/.github/workflows/run-integration-tests.yaml new file mode 100644 index 000000000..e911d3a90 --- /dev/null +++ b/.github/workflows/run-integration-tests.yaml @@ -0,0 +1,23 @@ +name: Run StochSS Integration Tests + +on: + push: + branches: [main, develop] + +jobs: + run-tests: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-20.04 ] + + steps: + - name: Initialize environment + id: checkout + uses: actions/checkout@v2 + + - name: Run Integration Tests + id: run_integration_tests + uses: ./ + with: + testin: '/stochss/stochss/tests/run_integration_tests.py' diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml new file mode 100644 index 000000000..6168fce28 --- /dev/null +++ b/.github/workflows/run-unit-tests.yml @@ -0,0 +1,21 @@ +name: Run StochSS Unit Tests + +on: [push] + +jobs: + run-tests: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-20.04 ] + + steps: + - name: Initialize environment + id: checkout + uses: actions/checkout@v2 + + - name: Run Unit Tests + id: run_unit_tests + uses: ./ + with: + testin: '/stochss/stochss/tests/run_unit_tests.py' From 6556b55848c9ef8a4df7df142bf070b8176a2fbe Mon Sep 17 00:00:00 2001 From: Bryan Rumsey Date: Thu, 9 Mar 2023 11:42:26 -0500 Subject: [PATCH 08/11] Config for time tests. --- .github/workflows/run-integration-tests.yaml | 7 +- stochss/tests/example_models.py | 750 ++++++++++-------- .../tests/integration_tests/test_gillespy2.py | 136 ++-- 3 files changed, 495 insertions(+), 398 deletions(-) diff --git a/.github/workflows/run-integration-tests.yaml b/.github/workflows/run-integration-tests.yaml index e911d3a90..e634abdf0 100644 --- a/.github/workflows/run-integration-tests.yaml +++ b/.github/workflows/run-integration-tests.yaml @@ -1,8 +1,9 @@ name: Run StochSS Integration Tests -on: - push: - branches: [main, develop] +on: [push] +# on: +# push: +# branches: [main, develop] jobs: run-tests: diff --git a/stochss/tests/example_models.py b/stochss/tests/example_models.py index 267a3c2db..7d2d9556c 100644 --- a/stochss/tests/example_models.py +++ b/stochss/tests/example_models.py @@ -22,329 +22,437 @@ Model, Species, Reaction, - Parameter + Parameter, + TimeSpan ) # pylint: disable=line-too-long # pylint: disable=missing-class-docstring # pylint: disable=too-few-public-methods -class Brusselator(Model): - def __init__(self): - Model.__init__(self, name="Brusselator") - self.volume = 1000 - - # Parameters - self.add_parameter(Parameter(name="rate1", expression="5000")) - self.add_parameter(Parameter(name="rate2", expression="50")) - self.add_parameter(Parameter(name="rate3", expression="5e-05")) - self.add_parameter(Parameter(name="rate4", expression="5")) - - # Variables - self.add_species(Species(name="A", initial_value=100000, mode="discrete")) - self.add_species(Species(name="B", initial_value=100000, mode="discrete")) - self.add_species(Species(name="C", initial_value=0, mode="discrete")) - self.add_species(Species(name="D", initial_value=0, mode="discrete")) - self.add_species(Species(name="X", initial_value=2000, mode="discrete")) - self.add_species(Species(name="Y", initial_value=1000, mode="discrete")) - - # Reactions - self.add_reaction(Reaction(name="reaction1", reactants={'A': 1}, products={'X': 1, 'A': 1}, propensity_function="rate1")) - self.add_reaction(Reaction(name="reaction2", reactants={'B': 1, 'X': 1}, products={'Y': 1, 'C': 1, 'B': 1}, propensity_function="rate2*X")) - self.add_reaction(Reaction(name="reaction3", reactants={'X': 2, 'Y': 1}, products={'X': 3}, propensity_function="rate3*Y*X*(X-1)/2")) - self.add_reaction(Reaction(name="reaction4", reactants={'X': 1}, products={'D': 1}, propensity_function="rate4*X")) - - # Timespan - self.timespan(np.arange(0, 30, 0.01)) - - -class Degradation(Model): - def __init__(self): - Model.__init__(self, name="Degradation") - self.volume = 1 - - # Parameters - self.add_parameter(Parameter(name="decayrate", expression="0.05")) - - # Variables - self.add_species(Species(name="protein", initial_value=50, mode="discrete")) - - # Reactions - self.add_reaction(Reaction(name="reaction", reactants={'protein': 1}, products={}, rate=self.listOfParameters["decayrate"])) - - # Timespan - self.timespan(np.arange(0, 100, 1)) - - -class Dimerization(Model): - def __init__(self): - Model.__init__(self, name="Dimerization") - self.volume = 1 - - # Parameters - self.add_parameter(Parameter(name="k_c", expression="0.005")) - self.add_parameter(Parameter(name="k_d", expression="0.08")) - - # Variables - self.add_species(Species(name="Monomer", initial_value=30, mode="discrete")) - self.add_species(Species(name="Dimer", initial_value=0, mode="discrete")) - - # Reactions - self.add_reaction(Reaction(name="r_creation", reactants={'Monomer': 2}, products={'Dimer': 1}, rate=self.listOfParameters["k_c"])) - self.add_reaction(Reaction(name="r_dissociation", reactants={'Dimer': 1}, products={'Monomer': 2}, rate=self.listOfParameters["k_d"])) - - # Timespan - self.timespan(np.arange(0, 100, 1)) - - -class LotkavolterraOscillator(Model): - def __init__(self): - Model.__init__(self, name="Lotkavolterra_Oscillator") - self.volume = 1 - - # Parameters - self.add_parameter(Parameter(name="k1", expression="0.004")) - self.add_parameter(Parameter(name="k2", expression="0.5")) - self.add_parameter(Parameter(name="k3", expression="0.0045")) - - # Variables - self.add_species(Species(name="R", initial_value=0.0095, mode="continuous")) - self.add_species(Species(name="W", initial_value=0.008, mode="continuous")) - - # Reactions - self.add_reaction(Reaction(name="r1", reactants={'R': 1}, products={'R': 2}, rate=self.listOfParameters["k1"])) - self.add_reaction(Reaction(name="r2", reactants={'R': 1, 'W': 1}, products={'W': 2}, rate=self.listOfParameters["k2"])) - self.add_reaction(Reaction(name="r3", reactants={'W': 1}, products={}, rate=self.listOfParameters["k3"])) - - # Timespan - self.timespan(np.arange(0, 9000, 1)) - - -class MichaelisMenten(Model): - def __init__(self): - Model.__init__(self, name="Michaelis_Menten") - self.volume = 1 - - # Parameters - self.add_parameter(Parameter(name="rate1", expression="0.0017")) - self.add_parameter(Parameter(name="rate2", expression="0.5")) - self.add_parameter(Parameter(name="rate3", expression="0.1")) - - # Variables - self.add_species(Species(name="A", initial_value=301, mode="discrete")) - self.add_species(Species(name="B", initial_value=120, mode="discrete")) - self.add_species(Species(name="C", initial_value=0, mode="discrete")) - self.add_species(Species(name="D", initial_value=0, mode="discrete")) - - # Reactions - self.add_reaction(Reaction(name="r1", reactants={'A': 1, 'B': 1}, products={'C': 1}, rate=self.listOfParameters["rate1"])) - self.add_reaction(Reaction(name="r2", reactants={'C': 1}, products={'A': 1, 'B': 1}, rate=self.listOfParameters["rate2"])) - self.add_reaction(Reaction(name="r3", reactants={'C': 1}, products={'B': 1, 'D': 1}, rate=self.listOfParameters["rate3"])) - - # Timespan - self.timespan(np.arange(0, 100, 1)) - - -class Opioid(Model): - def __init__(self): - Model.__init__(self, name="Opioid") - self.volume = 1 - - # Parameters - self.add_parameter(Parameter(name="alpha", expression="0.15")) - self.add_parameter(Parameter(name="epsilon", expression="0.8")) - self.add_parameter(Parameter(name="beta_p", expression="0.00266")) - self.add_parameter(Parameter(name="beta_a", expression="0.00094")) - self.add_parameter(Parameter(name="gamma", expression="0.00744")) - self.add_parameter(Parameter(name="zeta", expression="0.2")) - self.add_parameter(Parameter(name="delta", expression="0.1")) - self.add_parameter(Parameter(name="sigma", expression="0.9")) - self.add_parameter(Parameter(name="mu", expression="0.00729")) - self.add_parameter(Parameter(name="mu_prime", expression="0.01159")) - - # Variables - self.add_species(Species(name="Susceptible", initial_value=200, mode="discrete")) - self.add_species(Species(name="Prescribed_User", initial_value=0, mode="discrete")) - self.add_species(Species(name="Addicted", initial_value=0, mode="discrete")) - self.add_species(Species(name="Rehab", initial_value=0, mode="discrete")) - self.add_species(Species(name="Natural_Deaths", initial_value=0, mode="discrete")) - self.add_species(Species(name="Addicted_Deaths", initial_value=0, mode="discrete")) - - # Reactions - self.add_reaction(Reaction(name="SP", reactants={'Susceptible': 1}, products={'Prescribed_User': 1}, rate=self.listOfParameters["alpha"])) - self.add_reaction(Reaction(name="SA_a", reactants={'Susceptible': 1}, products={'Addicted': 1}, rate=self.listOfParameters["beta_a"])) - self.add_reaction(Reaction(name="SA_p", reactants={'Susceptible': 1}, products={'Addicted': 1}, rate=self.listOfParameters["beta_p"])) - self.add_reaction(Reaction(name="PA", reactants={'Prescribed_User': 1}, products={'Addicted': 1}, rate=self.listOfParameters["gamma"])) - self.add_reaction(Reaction(name="PS", reactants={'Prescribed_User': 1}, products={'Susceptible': 1}, rate=self.listOfParameters["epsilon"])) - self.add_reaction(Reaction(name="AR", reactants={'Addicted': 1}, products={'Rehab': 1}, rate=self.listOfParameters["zeta"])) - self.add_reaction(Reaction(name="RA", reactants={'Rehab': 1}, products={'Addicted': 1}, rate=self.listOfParameters["delta"])) - self.add_reaction(Reaction(name="RS", reactants={'Rehab': 1}, products={'Susceptible': 1}, rate=self.listOfParameters["sigma"])) - self.add_reaction(Reaction(name="mu_S", reactants={'Susceptible': 1}, products={'Susceptible': 1, 'Natural_Deaths': 1}, rate=self.listOfParameters["mu"])) - self.add_reaction(Reaction(name="mu_P", reactants={'Prescribed_User': 1}, products={'Susceptible': 1, 'Natural_Deaths': 1}, rate=self.listOfParameters["mu"])) - self.add_reaction(Reaction(name="mu_R", reactants={'Rehab': 1}, products={'Susceptible': 1, 'Natural_Deaths': 1}, rate=self.listOfParameters["mu"])) - self.add_reaction(Reaction(name="mu_prime_A", reactants={'Addicted': 1}, products={'Susceptible': 1, 'Addicted_Deaths': 1}, rate=self.listOfParameters["mu_prime"])) - - # Timespan - self.timespan(np.arange(0, 200, 1)) - - -class Schlogl(Model): - def __init__(self): - Model.__init__(self, name="Schlogl") - self.volume = 1 - - # Parameters - self.add_parameter(Parameter(name="k1", expression="1")) - self.add_parameter(Parameter(name="k2", expression="1")) - - # Variables - self.add_species(Species(name="s1", initial_value=300, mode="discrete")) - self.add_species(Species(name="s2", initial_value=300, mode="discrete")) - self.add_species(Species(name="s3", initial_value=300, mode="discrete")) - self.add_species(Species(name="s4", initial_value=300, mode="discrete")) - - # Reactions - self.add_reaction(Reaction(name="r1", reactants={'s1': 1, 's4': 1}, products={'s4': 2}, rate=self.listOfParameters["k1"])) - self.add_reaction(Reaction(name="r2", reactants={'s2': 1, 's4': 1}, products={'s3': 1}, rate=self.listOfParameters["k2"])) - - # Timespan - self.timespan(np.arange(0, 100000, 1000)) - - -class ToggleSwitch(Model): - def __init__(self): - Model.__init__(self, name="Toggle_Switch") - self.volume = 1 - - # Parameters - self.add_parameter(Parameter(name="alpha1", expression="10")) - self.add_parameter(Parameter(name="alpha2", expression="10")) - self.add_parameter(Parameter(name="beta", expression="2")) - self.add_parameter(Parameter(name="gamma", expression="2")) - self.add_parameter(Parameter(name="mu", expression="1")) - - # Variables - self.add_species(Species(name="A", initial_value=2, mode="discrete")) - self.add_species(Species(name="B", initial_value=2, mode="discrete")) - - # Reactions - self.add_reaction(Reaction(name="cu", reactants={}, products={'A': 1}, propensity_function="alpha1/(1+pow(B, beta))")) - self.add_reaction(Reaction(name="cv", reactants={}, products={'B': 1}, propensity_function="alpha2/(1+pow(A, gamma))")) - self.add_reaction(Reaction(name="du", reactants={'A': 1}, products={}, rate=self.listOfParameters["mu"])) - self.add_reaction(Reaction(name="dv", reactants={'B': 1}, products={}, rate=self.listOfParameters["mu"])) - - # Timespan - self.timespan(np.arange(0, 250, 1)) - - -class VilarOscillator(Model): - def __init__(self): - Model.__init__(self, name="Vilar_Oscillator") - self.volume = 1 - - # Parameters - self.add_parameter(Parameter(name="alphaA", expression="50")) - self.add_parameter(Parameter(name="alphaA_prime", expression="500")) - self.add_parameter(Parameter(name="alphaR", expression="0.01")) - self.add_parameter(Parameter(name="alphaR_prime", expression="50")) - self.add_parameter(Parameter(name="betaA", expression="50")) - self.add_parameter(Parameter(name="betaR", expression="5")) - self.add_parameter(Parameter(name="deltaMA", expression="10")) - self.add_parameter(Parameter(name="deltaMR", expression="0.5")) - self.add_parameter(Parameter(name="deltaA", expression="1")) - self.add_parameter(Parameter(name="deltaR", expression="0.2")) - self.add_parameter(Parameter(name="gammaA", expression="1")) - self.add_parameter(Parameter(name="gammaR", expression="1")) - self.add_parameter(Parameter(name="gammaC", expression="2")) - self.add_parameter(Parameter(name="thetaA", expression="50")) - self.add_parameter(Parameter(name="thetaR", expression="100")) - - # Variables - self.add_species(Species(name="Da", initial_value=1, mode="discrete")) - self.add_species(Species(name="Da_prime", initial_value=0, mode="discrete")) - self.add_species(Species(name="Ma", initial_value=0, mode="discrete")) - self.add_species(Species(name="Dr", initial_value=1, mode="discrete")) - self.add_species(Species(name="Dr_prime", initial_value=0, mode="discrete")) - self.add_species(Species(name="Mr", initial_value=0, mode="discrete")) - self.add_species(Species(name="C", initial_value=0, mode="discrete")) - self.add_species(Species(name="A", initial_value=0, mode="discrete")) - self.add_species(Species(name="R", initial_value=0, mode="discrete")) - - # Reactions - self.add_reaction(Reaction(name="r1", reactants={'A': 1, 'R': 1}, products={'C': 1}, rate="gammaC")) - self.add_reaction(Reaction(name="r2", reactants={'A': 1}, products={}, rate="deltaA")) - self.add_reaction(Reaction(name="r3", reactants={'C': 1}, products={'R': 1}, rate="deltaA")) - self.add_reaction(Reaction(name="r4", reactants={'R': 1}, products={}, rate="deltaR")) - self.add_reaction(Reaction(name="r5", reactants={'A': 1, 'Da': 1}, products={'Da_prime': 1}, rate="gammaA")) - self.add_reaction(Reaction(name="r6", reactants={'Da_prime': 1}, products={'A': 1, 'Da': 1}, rate="thetaA")) - self.add_reaction(Reaction(name="r7", reactants={'Da': 1}, products={'Da': 1, 'Ma': 1}, rate="alphaA")) - self.add_reaction(Reaction(name="r8", reactants={'Da_prime': 1}, products={'Da_prime': 1, 'Ma': 1}, rate="alphaA_prime")) - self.add_reaction(Reaction(name="r9", reactants={'Ma': 1}, products={}, rate="deltaMA")) - self.add_reaction(Reaction(name="r10", reactants={'Ma': 1}, products={'A': 1, 'Ma': 1}, rate="betaA")) - self.add_reaction(Reaction(name="r11", reactants={'A': 1, 'Dr': 1}, products={'Dr_prime': 1}, rate="gammaR")) - self.add_reaction(Reaction(name="r12", reactants={'Dr_prime': 1}, products={'A': 1, 'Dr': 1}, rate="thetaR")) - self.add_reaction(Reaction(name="r13", reactants={'Dr': 1}, products={'Dr': 1, 'Mr': 1}, rate="alphaR")) - self.add_reaction(Reaction(name="r14", reactants={'Dr_prime': 1}, products={'Dr_prime': 1, 'Mr': 1}, rate="alphaR_prime")) - self.add_reaction(Reaction(name="r15", reactants={'Mr': 1}, products={}, rate="deltaMR")) - self.add_reaction(Reaction(name="r16", reactants={'Mr': 1}, products={'Mr': 1, 'R': 1}, rate="betaR")) - - # Timespan - self.timespan(np.arange(0, 201, 1)) - - -class Oregonator(Model): - def __init__(self): - Model.__init__(self, name="Oregonator") - self.volume = 1 - - # Parameters - self.add_parameter(Parameter(name="k1", expression="2")) - self.add_parameter(Parameter(name="k2", expression="0.1")) - self.add_parameter(Parameter(name="k3", expression="104")) - self.add_parameter(Parameter(name="k4", expression="4e-07")) - self.add_parameter(Parameter(name="k5", expression="26")) - - # Variables - self.add_species(Species(name="F", initial_value=2, mode="continuous")) - self.add_species(Species(name="A", initial_value=250, mode="continuous")) - self.add_species(Species(name="B", initial_value=500, mode="continuous")) - self.add_species(Species(name="C", initial_value=1000, mode="continuous")) - self.add_species(Species(name="P", initial_value=0, mode="continuous")) - - # Reactions - self.add_reaction(Reaction(name="reaction1", reactants={'B': 1, 'F': 1}, products={'A': 1, 'F': 1}, rate=self.listOfParameters["k1"])) - self.add_reaction(Reaction(name="reaction2", reactants={'A': 1, 'B': 1}, products={'P': 1}, rate=self.listOfParameters["k2"])) - self.add_reaction(Reaction(name="reaction3", reactants={'A': 1, 'F': 1}, products={'A': 2, 'C': 1, 'F': 1}, rate=self.listOfParameters["k3"])) - self.add_reaction(Reaction(name="reaction4", reactants={'A': 2}, products={'P': 1}, rate=self.listOfParameters["k4"])) - self.add_reaction(Reaction(name="reaction5", reactants={'C': 1, 'F': 1}, products={'B': 1, 'F': 1}, rate=self.listOfParameters["k5"])) - - # Timespan - self.timespan(np.arange(0, 5, 0.1)) - - -class TysonOscillator(Model): - def __init__(self): - Model.__init__(self, name="Tyson_Oscillator") - self.volume = 300 - - # Parameters - self.add_parameter(Parameter(name="P", expression="2")) - self.add_parameter(Parameter(name="kt", expression="20")) - self.add_parameter(Parameter(name="kd", expression="1")) - self.add_parameter(Parameter(name="a0", expression="0.005")) - self.add_parameter(Parameter(name="a1", expression="0.05")) - self.add_parameter(Parameter(name="a2", expression="0.1")) - self.add_parameter(Parameter(name="kdx", expression="1")) - - # Variables - self.add_species(Species(name="X", initial_value=197, mode="discrete")) - self.add_species(Species(name="Y", initial_value=255, mode="discrete")) - - # Reactions - self.add_reaction(Reaction(name="rxn1", reactants={}, products={'X': 1}, propensity_function="vol*1/(1+(Y*Y/((vol*vol))))")) - self.add_reaction(Reaction(name="rxn2", reactants={'X': 1}, products={}, rate=self.listOfParameters["kdx"])) - self.add_reaction(Reaction(name="rxn3", reactants={'X': 1}, products={'X': 1, 'Y': 1}, rate=self.listOfParameters["kt"])) - self.add_reaction(Reaction(name="rxn4", reactants={'Y': 1}, products={}, rate=self.listOfParameters["kd"])) - self.add_reaction(Reaction(name="rxn5", reactants={'Y': 1}, products={}, propensity_function="Y/(a0 + a1*(Y/vol)+a2*Y*Y/(vol*vol))")) - - # Timespan - self.timespan(np.arange(0, 100, 1)) +def create_vilar_oscillator(parameter_values=None): + model = Model(name="VilarOscillator") + model.volume = 1 + + # Parameters + alphaA = Parameter(name="alphaA", expression=50) + alphaA_prime = Parameter(name="alphaA_prime", expression=500) + alphaR = Parameter(name="alphaR", expression=0.01) + alphaR_prime = Parameter(name="alphaR_prime", expression=50) + betaA = Parameter(name="betaA", expression=50) + betaR = Parameter(name="betaR", expression=5) + deltaMA = Parameter(name="deltaMA", expression=10) + deltaMR = Parameter(name="deltaMR", expression=0.5) + deltaA = Parameter(name="deltaA", expression=1) + deltaR = Parameter(name="deltaR", expression=0.2) + gammaA = Parameter(name="gammaA", expression=1) + gammaR = Parameter(name="gammaR", expression=1) + gammaC = Parameter(name="gammaC", expression=2) + thetaA = Parameter(name="thetaA", expression=50) + thetaR = Parameter(name="thetaR", expression=100) + model.add_parameter([ + alphaA, alphaA_prime, alphaR, alphaR_prime, betaA, betaR, deltaMA, deltaMR, deltaA, deltaR, gammaA, gammaR, gammaC, thetaA, thetaR + ]) + + # Species + Da = Species(name="Da", initial_value=1, mode="discrete") + Da_prime = Species(name="Da_prime", initial_value=0, mode="discrete") + Ma = Species(name="Ma", initial_value=0, mode="discrete") + Dr = Species(name="Dr", initial_value=1, mode="discrete") + Dr_prime = Species(name="Dr_prime", initial_value=0, mode="discrete") + Mr = Species(name="Mr", initial_value=0, mode="discrete") + C = Species(name="C", initial_value=0, mode="discrete") + A = Species(name="A", initial_value=0, mode="discrete") + R = Species(name="R", initial_value=0, mode="discrete") + model.add_species([Da, Da_prime, Ma, Dr, Dr_prime, Mr, C, A, R]) + + # Reactions + r01 = Reaction(name="r1", reactants={'A': 1, 'R': 1}, products={'C': 1}, rate="gammaC") + r02 = Reaction(name="r2", reactants={'A': 1}, products={}, rate="deltaA") + r03 = Reaction(name="r3", reactants={'C': 1}, products={'R': 1}, rate="deltaA") + r04 = Reaction(name="r4", reactants={'R': 1}, products={}, rate="deltaR") + r05 = Reaction(name="r5", reactants={'A': 1, 'Da': 1}, products={'Da_prime': 1}, rate="gammaA") + r06 = Reaction(name="r6", reactants={'Da_prime': 1}, products={'A': 1, 'Da': 1}, rate="thetaA") + r07 = Reaction(name="r7", reactants={'Da': 1}, products={'Da': 1, 'Ma': 1}, rate="alphaA") + r08 = Reaction(name="r8", reactants={'Da_prime': 1}, products={'Da_prime': 1, 'Ma': 1}, rate="alphaA_prime") + r09 = Reaction(name="r9", reactants={'Ma': 1}, products={}, rate="deltaMA") + r10 = Reaction(name="r10", reactants={'Ma': 1}, products={'A': 1, 'Ma': 1}, rate="betaA") + r11 = Reaction(name="r11", reactants={'A': 1, 'Dr': 1}, products={'Dr_prime': 1}, rate="gammaR") + r12 = Reaction(name="r12", reactants={'Dr_prime': 1}, products={'A': 1, 'Dr': 1}, rate="thetaR") + r13 = Reaction(name="r13", reactants={'Dr': 1}, products={'Dr': 1, 'Mr': 1}, rate="alphaR") + r14 = Reaction(name="r14", reactants={'Dr_prime': 1}, products={'Dr_prime': 1, 'Mr': 1}, rate="alphaR_prime") + r15 = Reaction(name="r15", reactants={'Mr': 1}, products={}, rate="deltaMR") + r16 = Reaction(name="r16", reactants={'Mr': 1}, products={'Mr': 1, 'R': 1}, rate="betaR") + model.add_reaction([r01, r02, r03, r04, r05, r06, r07, r08, r09, r10, r11, r12, r13, r14, r15, r16]) + + # Timespan + model.timespan(np.linspace(0,200,201)) + return model + +def create_dimerization(parameter_values=None): + model = Model(name="Dimerization") + + # Parameters + k_c = Parameter(name='k_c', expression=0.005) + k_d = Parameter(name='k_d', expression=0.08) + model.add_parameter([k_c, k_d]) + + # Species + m = Species(name='monomer', initial_value=30) + d = Species(name='dimer', initial_value=0) + model.add_species([m, d]) + + # Reactions + r_creation = Reaction(name="r_creation", rate=k_c, reactants={m:2}, products={d:1}) + r_dissociation = Reaction(name="r_dissociation", rate=k_d, reactants={d:1}, products={m:2}) + model.add_reaction([r_creation, r_dissociation]) + + # Timespan + model.timespan(np.linspace(0, 100, 101)) + return model + +def create_trichloroethylene(parameter_values=None): + model = Model(name="Trichloroethylene") + + # Species + A = Species(name='TCE', initial_value=300) + B = Species(name='Epoxide', initial_value=120) + C = Species(name='Dichloracatate', initial_value=0) + D = Species(name='LossOfOneCL', initial_value=0) + E = Species(name='Glyoxylate', initial_value=0) + F = Species(name='Output', initial_value=0) + model.add_species([A, B, C, D, E, F]) + + # Parameters + K1 = Parameter(name='K1', expression=0.00045 * 0.000025) + K2 = Parameter(name='K2', expression=14) + K3 = Parameter(name='K3', expression=0.033) + K4 = Parameter(name='K4', expression=500 * 0.0001) + K5 = Parameter(name='K5', expression=500 * 0.0001) + model.add_parameter([K1, K2, K3, K4, K5]) + + # Reactions + J1 = Reaction(name="J1", reactants={A: 1}, products={B: 1}, rate=K2) + J2 = Reaction(name="J2", reactants={B: 1}, products={C: 1}, rate=K3) + J3 = Reaction(name="J3", reactants={C: 1}, products={D: 1}, rate=K4) + J4 = Reaction(name="J4", reactants={D: 1}, products={E: 1}, rate=K4) + J5 = Reaction(name="J5", reactants={E: 1}, products={F: 1}, rate=K5) + model.add_reaction([J1, J2, J3, J4, J5]) + + model.timespan(np.linspace(0, 10000, 100)) + return model + +def create_lac_operon(parameter_values=None): + model = Model(name="LacOperon") + + # Species + s1 = Species(name='MR', initial_value=0) + s2 = Species(name='R', initial_value=0) + s3 = Species(name='R2', initial_value=0) + s4 = Species(name='O', initial_value=1) + s5 = Species(name='R2O', initial_value=0) + s6 = Species(name='I', initial_value=0) + s7 = Species(name='Iex', initial_value=0) + s8 = Species(name='I2R2', initial_value=0) + s9 = Species(name='MY', initial_value=0) + s10 = Species(name='Y', initial_value=0) + s11 = Species(name='YIex', initial_value=0) + s12 = Species(name='Ytot', initial_value=0) + model.add_species([s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12]) + + # Parameters + k1 = Parameter(name='k1', expression=0.111) + k2 = Parameter(name='k2', expression=15.0) + k3 = Parameter(name='k3', expression=103.8) + k4 = Parameter(name='k4', expression=0.001) + k5 = Parameter(name='k5', expression=1992.7) + k6 = Parameter(name='k6', expression=2.40) + k7 = Parameter(name='k7', expression=1.293e-6) + k8 = Parameter(name='k8', expression=12.0) + k9 = Parameter(name='k9', expression=1.293e-6) + k10 = Parameter(name='k10', expression=9963.2) + k11 = Parameter(name='k11', expression=0.50) + k12 = Parameter(name='k12', expression=0.010) + k13 = Parameter(name='k13', expression=30) + k14 = Parameter(name='k14', expression=0.249) + k15 = Parameter(name='k15', expression=0.10) + k16 = Parameter(name='k16', expression=60000) + k17 = Parameter(name='k17', expression=0.920) + k18 = Parameter(name='k18', expression=0.920) + k19 = Parameter(name='k19', expression=0.462) + k20 = Parameter(name='k20', expression=0.462) + k21 = Parameter(name='k21', expression=0.20) + k22 = Parameter(name='k22', expression=0.20) + k23 = Parameter(name='k23', expression=0.20) + k24 = Parameter(name='k24', expression=0.20) + k25 = Parameter(name='k25', expression=0.20) + model.add_parameter( + [k1, k2, k3, k4, k5, k6, k7, k8, k9, k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k20, k21, k22, k23, k24, k25 + ]) + + # Reactions + j1 = Reaction(name="j1", reactants={s12: 1}, products={s1: 1}, rate=k1) + j2 = Reaction(name="j2", reactants={s1: 1}, products={s1: 1, s2: 1}, rate=k2) + j3 = Reaction(name="j3", reactants={s2: 2}, products={s3: 1}, rate=k3) + j4 = Reaction(name="j4", reactants={s3: 1}, products={s2: 2}, rate=k4) + j5 = Reaction(name="j5", reactants={s3: 1, s4: 1}, products={s5: 1}, rate=k5) + j6 = Reaction(name="j6", reactants={s5: 1}, products={s3: 1, s4: 1}, rate=k6) + j7 = Reaction(name="j7", reactants={s6: 2, s3: 1}, products={s8: 1}, propensity_function='((3e-7)/((8e-16)*(6.0221367e14))**(2))*(R2)*(I)*(I-1)') + j8 = Reaction(name="j8", reactants={s8: 1}, products={s6: 2, s3: 1}, rate=k8) + j9 = Reaction(name="j9", reactants={s6: 2, s5: 1}, products={s8: 1, s4: 1}, propensity_function='((3e-7)/((8e-16)*(6.0221367e14))**(2))*(R2O)*(I)*(I-1)') + j10 = Reaction(name="j10", reactants={s8: 1, s4: 1}, products={s6: 2, s5: 1}, rate=k10) + j11 = Reaction(name="j11", reactants={s4: 1}, products={s4: 1, s9: 1}, rate=k11) + j12 = Reaction(name="j12", reactants={s5: 1}, products={s5: 1, s9: 1}, rate=k12) + j13 = Reaction(name="j13", reactants={s9: 1}, products={s9: 1, s10: 1}, rate=k13) + j14 = Reaction(name="j14", reactants={s10: 1, s7: 1}, products={s11: 1}, rate=k14) + j15 = Reaction(name="j15", reactants={s11: 1}, products={s10: 1, s7: 1}, rate=k15) + j16 = Reaction(name="j16", reactants={s11: 1}, products={s10: 1, s6: 1}, rate=k16) + j17 = Reaction(name="j17", reactants={s7: 1}, products={s6: 1}, rate=k17) + j18 = Reaction(name="j18", reactants={s6: 1}, products={s7: 1}, rate=k18) + j19 = Reaction(name="j19", reactants={s1: 1}, products={s12: 1}, rate=k19) + j20 = Reaction(name="j20", reactants={s9: 1}, products={s12: 1}, rate=k20) + j21 = Reaction(name="j21", reactants={s2: 1}, products={s12: 1}, rate=k21) + j22 = Reaction(name="j22", reactants={s3: 1}, products={s12: 1}, rate=k22) + j23 = Reaction(name="j23", reactants={s10: 1}, products={s12: 1}, rate=k23) + j24 = Reaction(name="j24", reactants={s11: 1}, products={s6: 1}, rate=k24) + j25 = Reaction(name="j25", reactants={s8: 1}, products={s6: 2}, rate=k25) + model.add_reaction( + [j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15, j16, j17, j18, j19, j20, j21, j22, j23, j24, j25 + ]) + + model.timespan(np.linspace(0, 100, 10)) + return model + +def create_schlogl(parameter_values=None): + model = Model(name="Schlogl") + + # Species + s1 = Species(name='A', initial_value=300) + s2 = Species(name='B', initial_value=300) + s3 = Species(name='C', initial_value=300) + s4 = Species(name='X', initial_value=300) + model.add_species([s1, s2, s3, s4]) + + k1 = Parameter(name='k1', expression=1) + k2 = Parameter(name='k2', expression=1) + model.add_parameter([k1, k2]) + + j1 = Reaction(name="j1", reactants={s1: 1, s4: 1}, products={s4: 2}, rate=k1) + j2 = Reaction(name="j2", reactants={s2: 1, s4: 1}, products={s3: 1}, rate=k2) + model.add_reaction([j1, j2]) + + model.timespan(np.linspace(0, 100000, 100)) + return model + +def create_michaelis_menten(parameter_values=None): + model = Model(name="Michaelis_Menten") + + # parameters + rate1 = Parameter(name='rate1', expression=0.0017) + rate2 = Parameter(name='rate2', expression=0.5) + rate3 = Parameter(name='rate3', expression=0.1) + model.add_parameter([rate1, rate2, rate3]) + + # Species + A = Species(name='A', initial_value=301) + B = Species(name='B', initial_value=120) + C = Species(name='C', initial_value=0) + D = Species(name='D', initial_value=0) + model.add_species([A, B, C, D]) + + # reactions + r1 = Reaction(name="r1", reactants={A: 1, B: 1}, products={C: 1}, rate=rate1) + r2 = Reaction(name="r2", reactants={C: 1}, products={A: 1, B: 1}, rate=rate2) + r3 = Reaction(name="r3", reactants={C: 1}, products={B: 1, D: 1}, rate=rate3) + model.add_reaction([r1, r2, r3]) + + model.timespan(np.linspace(0, 100, 101)) + return model + +def create_toggle_switch(parameter_values=None): + model = Model(name="Toggle_Switch") + + # Species + A = Species(name='A', initial_value=10) + B = Species(name='B', initial_value=10) + model.add_species([A, B]) + + # Parameters + alpha1 = Parameter(name='alpha1', expression=10) + alpha2 = Parameter(name='alpha2', expression=10) + beta = Parameter(name='beta', expression=2) + gamma = Parameter(name='gamma', expression=2) + mu = Parameter(name='mu', expression=1) + model.add_parameter([alpha1, alpha2, beta, gamma, mu]) + + # Reactions + model.add_reaction(Reaction(name="cu", reactants={}, products={'A': 1}, propensity_function="alpha1/(1+pow(B, beta))")) + model.add_reaction(Reaction(name="cv", reactants={}, products={'B': 1}, propensity_function="alpha2/(1+pow(A, gamma))")) + model.add_reaction(Reaction(name="du", reactants={'A': 1}, products={}, rate=model.listOfParameters["mu"])) + model.add_reaction(Reaction(name="dv", reactants={'B': 1}, products={}, rate=model.listOfParameters["mu"])) + + model.timespan(np.linspace(0, 250, 251)) + return model + +def create_decay(parameter_values=None): + model = Model(name="Example") + + # Species + S = Species(name='Sp', initial_value=100) + model.add_species([S]) + + # Parameters + k1 = Parameter(name='k1', expression=3.0) + model.add_parameter([k1]) + + # Reactions + rxn1 = Reaction(name='S degradation', reactants={S: 1}, products={}, rate=k1) + model.add_reaction([rxn1]) + + model.timespan(np.linspace(0, 20, 101)) + return model + +def create_tyson_2_state_oscillator(parameter_values=None): + model = Model(name="tyson-2-state", volume=300.0) + + # Species + X = Species(name='X', initial_value=int(0.65609071 * 300.0)) + Y = Species(name='Y', initial_value=int(0.85088331 * 300.0)) + model.add_species([X, Y]) + + # Parameters + P = Parameter(name='p', expression=2.0) + kt = Parameter(name='kt', expression=20.0) + kd = Parameter(name='kd', expression=1.0) + a0 = Parameter(name='a0', expression=0.005) + a1 = Parameter(name='a1', expression=0.05) + a2 = Parameter(name='a2', expression=0.1) + kdx = Parameter(name='kdx', expression=1.0) + model.add_parameter([P, kt, kd, a0, a1, a2, kdx]) + + # Reactions + rxn1 = Reaction( + name='X production', reactants={}, products={X: 1}, propensity_function='300 * 1.0 / (1.0 + (Y * Y / (300 * 300)))' + ) + rxn2 = Reaction(name='X degradation', reactants={X: 1}, products={}, rate=kdx) + rxn3 = Reaction(name='Y production', reactants={X: 1}, products={X: 1, Y: 1}, rate=kt) + rxn4 = Reaction(name='Y degradation', reactants={Y: 1}, products={}, rate=kd) + rxn5 = Reaction( + name='Y nonlin', reactants={Y: 1}, products={}, propensity_function='Y / a0 + a1 * (Y / 300) + a2 * Y * Y / (300 * 300)' + ) + model.add_reaction([rxn1, rxn2, rxn3, rxn4, rxn5]) + + model.timespan(np.linspace(0, 100, 101)) + return model + +def create_oregonator(parameter_values = None): + model = Model(name="Oregonator") + + # Species + F = Species(name="F", initial_value=2) + A = Species(name="A", initial_value=250) + B = Species(name="B", initial_value=500) + C = Species(name="C", initial_value=1000) + P = Species(name="P", initial_value=0) + model.add_species([F, A, B, C, P]) + + # Parameters (rates) + k1 = Parameter(name="k1", expression=2.0) + k2 = Parameter(name="k2", expression=0.1) + k3 = Parameter(name="k3", expression=104) + k4 = Parameter(name="k4", expression=4e-7) + k5 = Parameter(name="k5", expression=26.0) + model.add_parameter([k1, k2, k3, k4, k5]) + + # Reactions + reaction1 = Reaction(name="reaction1", reactants={B: 1, F: 1}, products={A: 1, F: 1}, rate=k1) + reaction2 = Reaction(name="reaction2", reactants={A: 1, B: 1}, products={P: 1}, rate=k2) + reaction3 = Reaction(name="reaction3", reactants={A: 1, F: 1}, products={A: 2, C: 1, F: 1}, rate=k3) + reaction4 = Reaction(name="reaction4", reactants={A: 2}, products={P: 1}, rate=k4) + reaction5 = Reaction(name="reaction5", reactants={C: 1, F: 1}, products={B: 1, F: 1}, rate=k5) + model.add_reaction([reaction1, reaction2, reaction3, reaction4, reaction5]) + + # Set timespan of model + model.timespan(np.linspace(0, 5, 501)) + return model + +def create_opioid(): + model = Model(name="Opioid") + + # Species + S = Species(name='Susceptibles', initial_value=1000) + P = Species(name='Prescribed_Users', initial_value=0) + A = Species(name='Addicted', initial_value=0) + R = Species(name='Rehab', initial_value=0) + Natural_Deaths = Species(name='Natural_Deaths', initial_value=0) + Addiction_Deaths = Species(name='Addiction_Deaths', initial_value=0) + model.add_species([S,P,A,R,Natural_Deaths,Addiction_Deaths]) + + # Parameters + alpha = Parameter(name='alpha', expression= 0.15) + epsilon = Parameter(name='epsilon', expression= 0.8) + beta_p = Parameter(name='beta_p', expression= 0.00266) + beta_a = Parameter(name='beta_a', expression= 0.00094) + gamma = Parameter(name='gamma', expression= 0.00744) + zeta = Parameter(name='zeta', expression= 0.2) + delta = Parameter(name='delta', expression= 0.1) + sigma = Parameter(name='sigma', expression= 0.9) + mu = Parameter(name='mu', expression= 0.00729) + mu_prime = Parameter(name='mu_prime', expression= 0.01159) + model.add_parameter([alpha, epsilon, beta_p, beta_a, gamma, zeta, delta, sigma, mu, mu_prime]) + + # Reactions + SP = Reaction( + name="SP", reactants={'Susceptibles': 1}, products={'Prescribed_Users': 1}, rate='alpha' + ) + SA_a = Reaction(name="SA_a", reactants={'Susceptibles': 1}, products={'Addicted': 1}, rate='beta_a') + SA_p = Reaction(name="SA_p", reactants={'Susceptibles': 1}, products={'Addicted': 1}, rate='beta_p') + mu_S = Reaction( + name="mu_S", reactants={'Susceptibles': 1}, products={'Susceptibles': 1, 'Natural_Deaths': 1}, rate='mu' + ) + PA = Reaction(name="PA", reactants={'Prescribed_Users': 1}, products={'Addicted': 1}, rate='gamma') + PS = Reaction( + name="PS", reactants={'Prescribed_Users': 1}, products={'Susceptibles': 1}, rate='epsilon' + ) + AR = Reaction(name="AR", reactants={'Addicted': 1}, products={'Rehab': 1}, rate='zeta') + RA = Reaction(name="RA", reactants={'Rehab': 1}, products={'Addicted': 1}, rate='delta') + RS = Reaction(name="RS", reactants={'Rehab': 1}, products={'Susceptibles': 1}, rate='sigma') + mu_P = Reaction( + name="mu_P", reactants={'Prescribed_Users': 1}, + products={'Susceptibles': 1, 'Natural_Deaths': 1}, rate='mu' + ) + mu_R = Reaction( + name="m_R", reactants={'Rehab': 1}, products={'Susceptibles': 1, 'Natural_Deaths': 1}, rate='mu' + ) + mu_prime_A = Reaction( + name="mu_prime_A", reactants={'Addicted': 1}, + products={'Susceptibles': 1, 'Addiction_Deaths': 1}, rate='mu_prime' + ) + model.add_reaction([SP, PS, SA_a, SA_p, PA, AR, RA, RS, mu_P, mu_R, mu_prime_A, mu_S]) + + # Timespan + tspan = TimeSpan.linspace(t=10, num_points=11) + model.timespan(tspan) + return model + +def create_telegraph_model(): + model = Model(name="on_off") + + # Species + ON = Species(name="ON", initial_value=0) + OFF = Species(name="OFF", initial_value=1) + model.add_species([ON, OFF]) + + # Parameters + kon = Parameter(name="kon", expression=0.1) + koff = Parameter(name="koff", expression=1.0) + model.add_parameter([kon, koff]) + + # Reactions + r1 = Reaction(name="on", reactants={'OFF': 1}, products= {'ON': 1}, rate='kon') + r2 = Reaction(name="off", reactants={'ON': 1}, products= {'OFF': 1}, rate='koff') + model.add_reaction([r1, r2]) + + # Timespan + tspan = TimeSpan.linspace(t=100, num_points=100) + model.timespan(tspan) + return model diff --git a/stochss/tests/integration_tests/test_gillespy2.py b/stochss/tests/integration_tests/test_gillespy2.py index 54e919006..b5c26153f 100644 --- a/stochss/tests/integration_tests/test_gillespy2.py +++ b/stochss/tests/integration_tests/test_gillespy2.py @@ -17,22 +17,15 @@ ''' import os +import time import unittest -from gillespy2 import GillesPySolver +import gillespy2 from example_models import ( - #Brusselator, - Degradation, - Dimerization, - LotkavolterraOscillator, - MichaelisMenten, - Opioid, - Schlogl, - ToggleSwitch, - VilarOscillator, - #Oregonator, - TysonOscillator + create_vilar_oscillator, create_dimerization, create_trichloroethylene, create_lac_operon, create_schlogl, + create_michaelis_menten, create_toggle_switch, create_decay, create_tyson_2_state_oscillator, + create_oregonator, create_opioid, create_telegraph_model ) os.chdir('/stochss') @@ -40,15 +33,21 @@ # pylint: disable=import-outside-toplevel class TestGillesPy2Dependency(unittest.TestCase): ''' - ################################################################################################ + #################################################################################################################### Unit tests for GillesPy2 dependency. - ################################################################################################ + #################################################################################################################### ''' def setUp(self): ''' Create a list of common example paths for each test. ''' - self.test_models = [#Brusselator, - Degradation, Dimerization, LotkavolterraOscillator, - MichaelisMenten, Opioid, Schlogl, ToggleSwitch, VilarOscillator] + self.test_ode_models = [] + self.test_ssa_models = [] + self.test_tau_models = [] + self.test_hybrid_models = [] + self.test_models = [ + create_vilar_oscillator, create_dimerization, create_trichloroethylene, create_lac_operon, create_schlogl, + create_michaelis_menten, create_toggle_switch, create_decay, create_tyson_2_state_oscillator, + create_oregonator, create_opioid, create_telegraph_model + ] ################################################################################################ # Unit tests for GillesPy2 dependency check_cpp_support. @@ -68,7 +67,7 @@ def test_get_best_solver(self): ''' Check if the get best solver function works in StochSS. ''' test_model = self.test_models[0]() test_solver = test_model.get_best_solver() - self.assertIsInstance(test_solver(model=test_model), GillesPySolver) + self.assertIsInstance(test_solver(model=test_model), gillespy2.GillesPySolver) ################################################################################################ # Unit tests for GillesPy2 dependency get_best_solver_algo. @@ -81,7 +80,7 @@ def test_get_best_solver_algo(self): for test_algo in test_algos: with self.subTest(test_algo=test_algo): test_solver = test_model.get_best_solver_algo(algorithm=test_algo) - self.assertIsInstance(test_solver(model=test_model), GillesPySolver) + self.assertIsInstance(test_solver(model=test_model), gillespy2.GillesPySolver) ################################################################################################ # Unit tests for GillesPy2 dependency solvers. @@ -89,95 +88,84 @@ def test_get_best_solver_algo(self): def test_ode_solver(self): ''' Check if the test_models run with the ODESolver. ''' - from gillespy2 import ODESolver - - #self.test_models.append(Oregonator) for model in self.test_models: test_model = model() - with self.subTest(model=test_model.name): - test_model.run(solver=ODESolver) - + msg = f"Running {test_model.name} using {gillespy2.ODESolver.name} failed!" + with self.subTest(msg=msg): + start = time.perf_counter() + test_model.run(solver=gillespy2.ODESolver, timeout=30) + print(f"Run time for {test_model.name} using {gillespy2.ODESolver.name}: {time.perf_counter() - start}") def test_ode_c_solver(self): ''' Check if the test_models run with the ODECSolver. ''' - from gillespy2 import ODECSolver - - #self.test_models.append(Oregonator) for model in self.test_models: test_model = model() - with self.subTest(model=test_model.name): - test_solver = ODECSolver(model=test_model) - test_model.run(solver=test_solver) - + test_solver = gillespy2.ODECSolver(model=test_model) + msg = f"Running {test_model.name} using {gillespy2.ODECSolver.name} failed!" + with self.subTest(msg=msg): + start = time.perf_counter() + test_model.run(solver=test_solver, timeout=30) + print(f"Run time for {test_model.name} using {gillespy2.ODECSolver.name}: {time.perf_counter() - start}") def test_numpy_ssa_solver(self): ''' Check if the test_models run with the NumPySSASolver. ''' - from gillespy2 import NumPySSASolver - - self.test_models.append(TysonOscillator) for model in self.test_models: test_model = model() - with self.subTest(model=test_model.name): - test_model.run(solver=NumPySSASolver) - + msg = f"Running {test_model.name} using {gillespy2.NumPySSASolver.name} failed!" + with self.subTest(msg=msg): + start = time.perf_counter() + test_model.run(solver=gillespy2.NumPySSASolver, timeout=30) + print(f"Run time for {test_model.name} using {gillespy2.NumPySSASolver.name}: {time.perf_counter() - start}") def test_ssa_c_solver(self): ''' Check if the test_models run with the SSACSolver. ''' - from gillespy2 import SSACSolver - - self.test_models.append(TysonOscillator) for model in self.test_models: test_model = model() - with self.subTest(model=test_model.name): - test_solver = SSACSolver(model=test_model) - test_model.run(solver=test_solver) - + test_solver = gillespy2.SSACSolver(model=test_model) + msg = f"Running {test_model.name} using {gillespy2.SSACSolver.name} failed!" + with self.subTest(msg=msg): + start = time.perf_counter() + test_model.run(solver=test_solver, timeout=30) + print(f"Run time for {test_model.name} using {gillespy2.SSACSolver.name}: {time.perf_counter() - start}") def test_tau_leaping_solver(self): ''' Check if the test_models run with the TauLeapingSolver. ''' - from gillespy2 import TauLeapingSolver - - self.test_models.append(TysonOscillator) for model in self.test_models: test_model = model() - with self.subTest(model=test_model.name): - test_model.run(solver=TauLeapingSolver) - + msg = f"Running {test_model.name} using {gillespy2.TauLeapingSolver.name} failed!" + with self.subTest(msg=msg): + start = time.perf_counter() + test_model.run(solver=gillespy2.TauLeapingSolver, timeout=30) + print(f"Run time for {test_model.name} using {gillespy2.TauLeapingSolver.name}: {time.perf_counter() - start}") def test_tau_leaping_c_solver(self): ''' Check if the test_models run with the TauLeapingCSolver. ''' - from gillespy2 import TauLeapingCSolver - - self.test_models.append(TysonOscillator) for model in self.test_models: test_model = model() - with self.subTest(model=test_model.name): - test_solver = TauLeapingCSolver(model=test_model) - test_model.run(solver=test_solver) - + test_solver = gillespy2.TauLeapingCSolver(model=test_model) + msg = f"Running {test_model.name} using {gillespy2.TauLeapingCSolver.name} failed!" + with self.subTest(msg=msg): + start = time.perf_counter() + test_model.run(solver=test_solver, timeout=30) + print(f"Run time for {test_model.name} using {gillespy2.TauLeapingCSolver.name}: {time.perf_counter() - start}") def test_tau_hybrid_solver(self): ''' Check if the test_models run with the TauHybridSolver. ''' - from gillespy2 import TauHybridSolver - - #self.test_models.append(Oregonator) - self.test_models.append(TysonOscillator) - self.test_models.remove(VilarOscillator) for model in self.test_models: test_model = model() - with self.subTest(model=test_model.name): - test_model.run(solver=TauHybridSolver) - + msg = f"Running {test_model.name} using {gillespy2.TauHybridSolver.name} failed!" + with self.subTest(msg=msg): + start = time.perf_counter() + test_model.run(solver=gillespy2.TauHybridSolver, timeout=30) + print(f"Run time for {test_model.name} using {gillespy2.TauHybridSolver.name}: {time.perf_counter() - start}") def test_tau_hybrid_c_solver(self): ''' Check if the test_models run with the TauHybridCSolver. ''' - from gillespy2 import TauHybridCSolver - - #self.test_models.append(Oregonator) - self.test_models.append(TysonOscillator) - self.test_models.remove(VilarOscillator) - self.test_models.remove(ToggleSwitch) for model in self.test_models: test_model = model() - with self.subTest(model=test_model.name): - test_model.run(solver=TauHybridCSolver) + test_solver = gillespy2.TauHybridCSolver(model=test_model) + msg = f"Running {test_model.name} using {gillespy2.TauHybridCSolver.name} failed!" + with self.subTest(msg=msg): + start = time.perf_counter() + test_model.run(solver=test_solver, timeout=30) + print(f"Run time for {test_model.name} using {gillespy2.TauHybridCSolver.name}: {time.perf_counter() - start}") From 19667006bfefc7153922d53e0433ca517c9fb5c9 Mon Sep 17 00:00:00 2001 From: Bryan Rumsey Date: Thu, 9 Mar 2023 12:54:56 -0500 Subject: [PATCH 09/11] Removed long running models. --- .../tests/integration_tests/test_gillespy2.py | 65 ++++++++----------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/stochss/tests/integration_tests/test_gillespy2.py b/stochss/tests/integration_tests/test_gillespy2.py index b5c26153f..60f09e33d 100644 --- a/stochss/tests/integration_tests/test_gillespy2.py +++ b/stochss/tests/integration_tests/test_gillespy2.py @@ -15,9 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . ''' - import os -import time import unittest import gillespy2 @@ -39,19 +37,24 @@ class TestGillesPy2Dependency(unittest.TestCase): ''' def setUp(self): ''' Create a list of common example paths for each test. ''' - self.test_ode_models = [] - self.test_ssa_models = [] - self.test_tau_models = [] - self.test_hybrid_models = [] - self.test_models = [ + self.test_ode_models = [ create_vilar_oscillator, create_dimerization, create_trichloroethylene, create_lac_operon, create_schlogl, create_michaelis_menten, create_toggle_switch, create_decay, create_tyson_2_state_oscillator, create_oregonator, create_opioid, create_telegraph_model ] + self.test_ssa_models = [ + create_vilar_oscillator, create_dimerization, create_trichloroethylene, create_schlogl, + create_michaelis_menten, create_toggle_switch, create_decay, create_tyson_2_state_oscillator, + create_opioid, create_telegraph_model + ] + self.test_hybrid_models = [ + create_dimerization, create_trichloroethylene, create_schlogl, create_michaelis_menten, + create_toggle_switch, create_decay, create_opioid, create_telegraph_model + ] - ################################################################################################ + #################################################################################################################### # Unit tests for GillesPy2 dependency check_cpp_support. - ################################################################################################ + #################################################################################################################### def test_check_cpp_support(self): ''' Check if the check cpp support functions works in StochSS. ''' @@ -59,9 +62,9 @@ def test_check_cpp_support(self): self.assertIsInstance(check_cpp_support(), bool) - ################################################################################################ + #################################################################################################################### # Unit tests for GillesPy2 dependency get_best_solver. - ################################################################################################ + #################################################################################################################### def test_get_best_solver(self): ''' Check if the get best solver function works in StochSS. ''' @@ -69,9 +72,9 @@ def test_get_best_solver(self): test_solver = test_model.get_best_solver() self.assertIsInstance(test_solver(model=test_model), gillespy2.GillesPySolver) - ################################################################################################ + #################################################################################################################### # Unit tests for GillesPy2 dependency get_best_solver_algo. - ################################################################################################ + #################################################################################################################### def test_get_best_solver_algo(self): ''' Check if the get best solver algo function works in StochSS. ''' @@ -82,90 +85,74 @@ def test_get_best_solver_algo(self): test_solver = test_model.get_best_solver_algo(algorithm=test_algo) self.assertIsInstance(test_solver(model=test_model), gillespy2.GillesPySolver) - ################################################################################################ + #################################################################################################################### # Unit tests for GillesPy2 dependency solvers. - ################################################################################################ + #################################################################################################################### def test_ode_solver(self): ''' Check if the test_models run with the ODESolver. ''' - for model in self.test_models: + for model in self.test_ode_models: test_model = model() msg = f"Running {test_model.name} using {gillespy2.ODESolver.name} failed!" with self.subTest(msg=msg): - start = time.perf_counter() test_model.run(solver=gillespy2.ODESolver, timeout=30) - print(f"Run time for {test_model.name} using {gillespy2.ODESolver.name}: {time.perf_counter() - start}") def test_ode_c_solver(self): ''' Check if the test_models run with the ODECSolver. ''' - for model in self.test_models: + for model in self.test_ode_models: test_model = model() test_solver = gillespy2.ODECSolver(model=test_model) msg = f"Running {test_model.name} using {gillespy2.ODECSolver.name} failed!" with self.subTest(msg=msg): - start = time.perf_counter() test_model.run(solver=test_solver, timeout=30) - print(f"Run time for {test_model.name} using {gillespy2.ODECSolver.name}: {time.perf_counter() - start}") def test_numpy_ssa_solver(self): ''' Check if the test_models run with the NumPySSASolver. ''' - for model in self.test_models: + for model in self.test_ssa_models: test_model = model() msg = f"Running {test_model.name} using {gillespy2.NumPySSASolver.name} failed!" with self.subTest(msg=msg): - start = time.perf_counter() test_model.run(solver=gillespy2.NumPySSASolver, timeout=30) - print(f"Run time for {test_model.name} using {gillespy2.NumPySSASolver.name}: {time.perf_counter() - start}") def test_ssa_c_solver(self): ''' Check if the test_models run with the SSACSolver. ''' - for model in self.test_models: + for model in self.test_ssa_models: test_model = model() test_solver = gillespy2.SSACSolver(model=test_model) msg = f"Running {test_model.name} using {gillespy2.SSACSolver.name} failed!" with self.subTest(msg=msg): - start = time.perf_counter() test_model.run(solver=test_solver, timeout=30) - print(f"Run time for {test_model.name} using {gillespy2.SSACSolver.name}: {time.perf_counter() - start}") def test_tau_leaping_solver(self): ''' Check if the test_models run with the TauLeapingSolver. ''' - for model in self.test_models: + for model in self.test_ssa_models: test_model = model() msg = f"Running {test_model.name} using {gillespy2.TauLeapingSolver.name} failed!" with self.subTest(msg=msg): - start = time.perf_counter() test_model.run(solver=gillespy2.TauLeapingSolver, timeout=30) - print(f"Run time for {test_model.name} using {gillespy2.TauLeapingSolver.name}: {time.perf_counter() - start}") def test_tau_leaping_c_solver(self): ''' Check if the test_models run with the TauLeapingCSolver. ''' - for model in self.test_models: + for model in self.test_ssa_models: test_model = model() test_solver = gillespy2.TauLeapingCSolver(model=test_model) msg = f"Running {test_model.name} using {gillespy2.TauLeapingCSolver.name} failed!" with self.subTest(msg=msg): - start = time.perf_counter() test_model.run(solver=test_solver, timeout=30) - print(f"Run time for {test_model.name} using {gillespy2.TauLeapingCSolver.name}: {time.perf_counter() - start}") def test_tau_hybrid_solver(self): ''' Check if the test_models run with the TauHybridSolver. ''' - for model in self.test_models: + for model in self.test_hybrid_models: test_model = model() msg = f"Running {test_model.name} using {gillespy2.TauHybridSolver.name} failed!" with self.subTest(msg=msg): - start = time.perf_counter() test_model.run(solver=gillespy2.TauHybridSolver, timeout=30) - print(f"Run time for {test_model.name} using {gillespy2.TauHybridSolver.name}: {time.perf_counter() - start}") def test_tau_hybrid_c_solver(self): ''' Check if the test_models run with the TauHybridCSolver. ''' - for model in self.test_models: + for model in self.test_hybrid_models: test_model = model() test_solver = gillespy2.TauHybridCSolver(model=test_model) msg = f"Running {test_model.name} using {gillespy2.TauHybridCSolver.name} failed!" with self.subTest(msg=msg): - start = time.perf_counter() test_model.run(solver=test_solver, timeout=30) - print(f"Run time for {test_model.name} using {gillespy2.TauHybridCSolver.name}: {time.perf_counter() - start}") From 6e6033a07ef32b4c37d71b2b684bfdc32ae47e8a Mon Sep 17 00:00:00 2001 From: Bryan Rumsey Date: Thu, 9 Mar 2023 13:00:57 -0500 Subject: [PATCH 10/11] Fixed broken test. --- stochss/tests/integration_tests/test_gillespy2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stochss/tests/integration_tests/test_gillespy2.py b/stochss/tests/integration_tests/test_gillespy2.py index 60f09e33d..7c2112a18 100644 --- a/stochss/tests/integration_tests/test_gillespy2.py +++ b/stochss/tests/integration_tests/test_gillespy2.py @@ -68,7 +68,7 @@ def test_check_cpp_support(self): def test_get_best_solver(self): ''' Check if the get best solver function works in StochSS. ''' - test_model = self.test_models[0]() + test_model = self.test_ode_models[0]() test_solver = test_model.get_best_solver() self.assertIsInstance(test_solver(model=test_model), gillespy2.GillesPySolver) @@ -79,7 +79,7 @@ def test_get_best_solver(self): def test_get_best_solver_algo(self): ''' Check if the get best solver algo function works in StochSS. ''' test_algos = ["ODE", "SSA", "CLE", "Tau-Leaping", "Tau-Hybrid"] - test_model = self.test_models[0]() + test_model = self.test_ode_models[0]() for test_algo in test_algos: with self.subTest(test_algo=test_algo): test_solver = test_model.get_best_solver_algo(algorithm=test_algo) From f1d575faa0b843a841460089dbdb7511b320d3e6 Mon Sep 17 00:00:00 2001 From: Bryan Rumsey Date: Thu, 9 Mar 2023 13:15:21 -0500 Subject: [PATCH 11/11] Finished time checks. --- .github/workflows/run-integration-tests.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-integration-tests.yaml b/.github/workflows/run-integration-tests.yaml index e634abdf0..e911d3a90 100644 --- a/.github/workflows/run-integration-tests.yaml +++ b/.github/workflows/run-integration-tests.yaml @@ -1,9 +1,8 @@ name: Run StochSS Integration Tests -on: [push] -# on: -# push: -# branches: [main, develop] +on: + push: + branches: [main, develop] jobs: run-tests: