From 37c5ed1809a9a1bb35b184bf6e914a0e49440ab8 Mon Sep 17 00:00:00 2001 From: alex patrie Date: Wed, 19 Jul 2023 18:03:52 -0400 Subject: [PATCH 01/18] feat: added deps to requirements and configured setup file --- requirements.txt | 5 +- setup.py | 32 ++++++----- vivarium_tellurium.egg-info/PKG-INFO | 56 +++++++++++++++++++ vivarium_tellurium.egg-info/SOURCES.txt | 13 +++++ .../dependency_links.txt | 1 + vivarium_tellurium.egg-info/requires.txt | 4 ++ vivarium_tellurium.egg-info/top_level.txt | 1 + 7 files changed, 97 insertions(+), 15 deletions(-) create mode 100644 vivarium_tellurium.egg-info/PKG-INFO create mode 100644 vivarium_tellurium.egg-info/SOURCES.txt create mode 100644 vivarium_tellurium.egg-info/dependency_links.txt create mode 100644 vivarium_tellurium.egg-info/requires.txt create mode 100644 vivarium_tellurium.egg-info/top_level.txt diff --git a/requirements.txt b/requirements.txt index 1665c97..023b166 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,7 @@ # pip install -r requirements.txt # --e . \ No newline at end of file + +vivarium-core +tellurium +biosimulators-utils diff --git a/setup.py b/setup.py index d7996bf..9d9daa0 100644 --- a/setup.py +++ b/setup.py @@ -7,29 +7,33 @@ long_description = readme.read() setup( - name='', # TODO: Put your package name here. + name='vivarium-tellurium', version='0.0.1', packages=[ - # TODO: Replace 'template' with the name of your folder. - 'template', - 'template.processes', - 'template.composites', - 'template.experiments', + 'vivarium_tellurium', + 'vivarium_tellurium.processes', + 'vivarium_tellurium.composites', + 'vivarium_tellurium.experiments', ], - author='', # TODO: Put your name here. - author_email='', # TODO: Put your email here. - url='', # TODO: Put your project URL here. - license='', # TODO: Choose a license. + author='Alex Patrie, Eran Agmon', + author_email='', + url='https://github.com/vivarium-collective/vivarium-tellurium', + license='', entry_points={ - 'console_scripts': []}, - short_description='', # TODO: Describe your project briefely. + 'console_scripts': [], + }, + short_description='A Vivarium interface for Tellurium', long_description=long_description, long_description_content_type='text/markdown', package_data={}, include_package_data=True, install_requires=[ - 'vivarium-core>=1.0.0', + 'tellurium', + 'vivarium-core', + 'biosimulators-utils', + 'pytest', + ], + tests_require=[ 'pytest', - # TODO: Add other dependencies. ], ) diff --git a/vivarium_tellurium.egg-info/PKG-INFO b/vivarium_tellurium.egg-info/PKG-INFO new file mode 100644 index 0000000..6d75da9 --- /dev/null +++ b/vivarium_tellurium.egg-info/PKG-INFO @@ -0,0 +1,56 @@ +Metadata-Version: 2.1 +Name: vivarium-tellurium +Version: 0.0.1 +Home-page: https://github.com/vivarium-collective/vivarium-tellurium +Author: Alex Patrie, Eran Agmon +Author-email: +Description-Content-Type: text/markdown + +# Template Vivarium Project + +Visit [the Vivarium Core +documentation](https://vivarium-core.readthedocs.io/) to learn how to +use the core Vivarium engine to create computational biology models. +Check out the +[getting started](https://vivarium-core.readthedocs.io/en/latest/getting_started.html) +guide of the documentation. + +## Using this Template +This repository contains a skeleton project you can build on to create +your own models. Go to the +[github page](https://github.com/vivarium-collective/vivarium-template) +and select `use this template`. + +What follows is a template `README.md`. + + + +------------------------------------------------------------------------ + +# Project Name + + + +Introduction to your project. + + + +## Installation + +Explain how users can get up and running. + + diff --git a/vivarium_tellurium.egg-info/SOURCES.txt b/vivarium_tellurium.egg-info/SOURCES.txt new file mode 100644 index 0000000..134a065 --- /dev/null +++ b/vivarium_tellurium.egg-info/SOURCES.txt @@ -0,0 +1,13 @@ +README.md +setup.py +vivarium_tellurium/__init__.py +vivarium_tellurium.egg-info/PKG-INFO +vivarium_tellurium.egg-info/SOURCES.txt +vivarium_tellurium.egg-info/dependency_links.txt +vivarium_tellurium.egg-info/requires.txt +vivarium_tellurium.egg-info/top_level.txt +vivarium_tellurium/composites/__init__.py +vivarium_tellurium/composites/injected_glc_phosphorylation.py +vivarium_tellurium/experiments/__init__.py +vivarium_tellurium/processes/__init__.py +vivarium_tellurium/processes/tellurium_process.py \ No newline at end of file diff --git a/vivarium_tellurium.egg-info/dependency_links.txt b/vivarium_tellurium.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/vivarium_tellurium.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/vivarium_tellurium.egg-info/requires.txt b/vivarium_tellurium.egg-info/requires.txt new file mode 100644 index 0000000..41d4a6c --- /dev/null +++ b/vivarium_tellurium.egg-info/requires.txt @@ -0,0 +1,4 @@ +tellurium +vivarium-core +biosimulators-utils +pytest diff --git a/vivarium_tellurium.egg-info/top_level.txt b/vivarium_tellurium.egg-info/top_level.txt new file mode 100644 index 0000000..ae3ef46 --- /dev/null +++ b/vivarium_tellurium.egg-info/top_level.txt @@ -0,0 +1 @@ +vivarium_tellurium From 7051017e7711ebaabaf7cc9a636bc61fcbb2877d Mon Sep 17 00:00:00 2001 From: alex patrie Date: Wed, 19 Jul 2023 18:25:15 -0400 Subject: [PATCH 02/18] chore: removed unused imports and added comments for build --- .../composites/injected_glc_phosphorylation.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/vivarium_tellurium/composites/injected_glc_phosphorylation.py b/vivarium_tellurium/composites/injected_glc_phosphorylation.py index 0f33e16..4c33a2e 100644 --- a/vivarium_tellurium/composites/injected_glc_phosphorylation.py +++ b/vivarium_tellurium/composites/injected_glc_phosphorylation.py @@ -10,10 +10,6 @@ from vivarium.core.engine import Engine from vivarium.core.composer import Composer -from vivarium.library.pretty import format_dict -from vivarium.processes.injector import Injector - -from template.processes.glucose_phosphorylation import GlucosePhosphorylation class InjectedGlcPhosphorylation(Composer): @@ -34,14 +30,14 @@ def __init__(self, config): super().__init__(config) def generate_processes(self, config): - injector = Injector(self.config['injector']) + '''injector = Injector(self.config['injector']) glucose_phosphorylation = GlucosePhosphorylation( self.config['glucose_phosphorylation']) return { 'injector': injector, 'glucose_phosphorylation': glucose_phosphorylation, - } + }''' def generate_topology(self, config): return { From 907bcd77e97bb49fcbd4e034e4bb5ef0db30ca5d Mon Sep 17 00:00:00 2001 From: alex patrie Date: Wed, 19 Jul 2023 18:28:07 -0400 Subject: [PATCH 03/18] fix: added return statement --- vivarium_tellurium/composites/injected_glc_phosphorylation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/vivarium_tellurium/composites/injected_glc_phosphorylation.py b/vivarium_tellurium/composites/injected_glc_phosphorylation.py index 4c33a2e..c979e2d 100644 --- a/vivarium_tellurium/composites/injected_glc_phosphorylation.py +++ b/vivarium_tellurium/composites/injected_glc_phosphorylation.py @@ -38,6 +38,7 @@ def generate_processes(self, config): 'injector': injector, 'glucose_phosphorylation': glucose_phosphorylation, }''' + return None def generate_topology(self, config): return { From 0ae9bc7be23df03046902d5643cd36d6e39d1e0c Mon Sep 17 00:00:00 2001 From: alex patrie Date: Wed, 19 Jul 2023 18:38:40 -0400 Subject: [PATCH 04/18] fix: created test process file and imported tellurium for pytest --- .github/workflows/pytest.yml | 29 +++++------ .../experiments/test_tellurium_process.py | 48 +++++++++++++++++++ .../processes/tellurium_process.py | 43 +---------------- 3 files changed, 65 insertions(+), 55 deletions(-) create mode 100644 vivarium_tellurium/experiments/test_tellurium_process.py diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 1fdc673..199656f 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -7,24 +7,25 @@ on: branches: [master] pull_request: branches: [master] + workflow_dispatch: jobs: build: - runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8', '3.9', '3.10'] + python-version: [3.8] steps: - - uses: actions/checkout@v2 - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Test with pytest - run: | - pytest + - uses: actions/checkout@v2 + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Test with pytest + run: | + pytest diff --git a/vivarium_tellurium/experiments/test_tellurium_process.py b/vivarium_tellurium/experiments/test_tellurium_process.py new file mode 100644 index 0000000..b4ad9d5 --- /dev/null +++ b/vivarium_tellurium/experiments/test_tellurium_process.py @@ -0,0 +1,48 @@ +from vivarium.core.engine import Engine, pp +from vivarium_tellurium.processes.tellurium_process import TelluriumProcess + +""" +Test implementation file of a `TelluriumProcess` instance for Pytest. +""" + + +def test_tellurium(): + totaltime = 10.0 + + # initialize the process + config = {} + tellurium_process = TelluriumProcess(config) + + # declare the initial state, mirroring the ports structure + initial_state = { + 'internal': { + 'A': 0.0 + }, + 'external': { + 'A': 1.0 + }, + } + + ports = tellurium_process.ports_schema() + print('PORTS') + print(ports) + + # make the simulation + sim = Engine( + processes={'tellurium_process': tellurium_process}, + topology={'tellurium_process': {port_id: (port_id,) for port_id in ports.keys()}}, + initial_state=initial_state + ) + + # run the simulation + sim.update(totaltime) + + # get the results + data = sim.emitter.get_data() + + print(pp(data)) + + + +if __name__ == '__main__': + test_tellurium() \ No newline at end of file diff --git a/vivarium_tellurium/processes/tellurium_process.py b/vivarium_tellurium/processes/tellurium_process.py index 50cfa13..fb98e84 100644 --- a/vivarium_tellurium/processes/tellurium_process.py +++ b/vivarium_tellurium/processes/tellurium_process.py @@ -1,8 +1,8 @@ +import json +import tellurium as te from vivarium.core.process import Process from vivarium.core.engine import Engine, pp -# TODO import tellurium - class TelluriumProcess(Process): ''' Vivarium Process for Tellurium ''' @@ -73,43 +73,4 @@ def next_update(self, interval, states): -def test_tellurium(): - totaltime = 10.0 - - # initialize the process - config = {} - tellurium_process = TelluriumProcess(config) - - # declare the initial state, mirroring the ports structure - initial_state = { - 'internal': { - 'A': 0.0 - }, - 'external': { - 'A': 1.0 - }, - } - - ports = tellurium_process.ports_schema() - print('PORTS') - print(ports) - - # make the simulation - sim = Engine( - processes={'tellurium_process': tellurium_process}, - topology={'tellurium_process': {port_id: (port_id,) for port_id in ports.keys()}}, - initial_state=initial_state - ) - - # run the simulation - sim.update(totaltime) - - # get the results - data = sim.emitter.get_data() - - print(pp(data)) - -# run module with python template/processes/template_process.py -if __name__ == '__main__': - test_tellurium() From 3339b5457ca66b12f4ec4b82f769c5cfe512e2b5 Mon Sep 17 00:00:00 2001 From: alex patrie Date: Wed, 19 Jul 2023 18:42:33 -0400 Subject: [PATCH 05/18] fix: removed exec for pytest --- vivarium_tellurium/experiments/test_tellurium_process.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/vivarium_tellurium/experiments/test_tellurium_process.py b/vivarium_tellurium/experiments/test_tellurium_process.py index b4ad9d5..7b6f863 100644 --- a/vivarium_tellurium/experiments/test_tellurium_process.py +++ b/vivarium_tellurium/experiments/test_tellurium_process.py @@ -42,7 +42,3 @@ def test_tellurium(): print(pp(data)) - - -if __name__ == '__main__': - test_tellurium() \ No newline at end of file From 3568dc7ecb6cf444332cb3d6f841089f5e87f45c Mon Sep 17 00:00:00 2001 From: alex patrie Date: Wed, 19 Jul 2023 18:47:42 -0400 Subject: [PATCH 06/18] chore: added tellurium deps to requirements --- requirements.txt | 22 ++++++++++++++++++++++ vivarium_tellurium.egg-info/SOURCES.txt | 1 + 2 files changed, 23 insertions(+) diff --git a/requirements.txt b/requirements.txt index 023b166..d7ce44f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,3 +15,25 @@ vivarium-core tellurium biosimulators-utils +numpy>=1.23 +scipy>=1.5.1 +matplotlib>=2.0.2 +pandas>=0.20.2 +libroadrunner>=2.1 +rrplugins>=2.1; platform_system == "Windows" +phrasedml>=1.0.9; (platform_machine != "arm64") +antimony>=2.12.0 +sbml2matlab>=0.9.1; (python_version < '3.10' and platform_machine != "arm64") +python-libsbml>=5.18.0 +python-libnuml>=1.0.0 +python-libsedml>=2.0.17 +python-libcombine>=0.2.2 +appdirs>=1.4.3 +jinja2>=3.0.0 +plotly>=2.0.12 +requests +jupyter-client>=5.1.0 +jupyter-core>=4.3.0 +ipython +ipykernel>=4.6.1 +pytest \ No newline at end of file diff --git a/vivarium_tellurium.egg-info/SOURCES.txt b/vivarium_tellurium.egg-info/SOURCES.txt index 134a065..3b35f90 100644 --- a/vivarium_tellurium.egg-info/SOURCES.txt +++ b/vivarium_tellurium.egg-info/SOURCES.txt @@ -9,5 +9,6 @@ vivarium_tellurium.egg-info/top_level.txt vivarium_tellurium/composites/__init__.py vivarium_tellurium/composites/injected_glc_phosphorylation.py vivarium_tellurium/experiments/__init__.py +vivarium_tellurium/experiments/test_tellurium_process.py vivarium_tellurium/processes/__init__.py vivarium_tellurium/processes/tellurium_process.py \ No newline at end of file From a3f3fbf7b0616d814ed2cc58d7ac487b77b1c4f4 Mon Sep 17 00:00:00 2001 From: alex patrie Date: Wed, 19 Jul 2023 19:00:02 -0400 Subject: [PATCH 07/18] fix: removed tests require param from setup --- setup.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup.py b/setup.py index 9d9daa0..9ebe8e9 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,4 @@ 'biosimulators-utils', 'pytest', ], - tests_require=[ - 'pytest', - ], ) From 113c5046d17f142117584f88a7074766c1cd44bc Mon Sep 17 00:00:00 2001 From: alex patrie Date: Thu, 20 Jul 2023 12:30:16 -0400 Subject: [PATCH 08/18] chore: added gitignore file-removed unused deps-removed egg dir and test file --- .github/workflows/pytest.yml | 2 +- .gitignore | 1 + requirements.txt | 21 ------- setup.py | 2 +- vivarium_tellurium.egg-info/PKG-INFO | 56 ------------------- vivarium_tellurium.egg-info/SOURCES.txt | 14 ----- .../dependency_links.txt | 1 - vivarium_tellurium.egg-info/requires.txt | 4 -- vivarium_tellurium.egg-info/top_level.txt | 1 - .../injected_glc_phosphorylation.py | 52 ----------------- .../experiments/test_tellurium_process.py | 44 --------------- .../processes/tellurium_process.py | 39 +++++++++++++ 12 files changed, 42 insertions(+), 195 deletions(-) create mode 100644 .gitignore delete mode 100644 vivarium_tellurium.egg-info/PKG-INFO delete mode 100644 vivarium_tellurium.egg-info/SOURCES.txt delete mode 100644 vivarium_tellurium.egg-info/dependency_links.txt delete mode 100644 vivarium_tellurium.egg-info/requires.txt delete mode 100644 vivarium_tellurium.egg-info/top_level.txt delete mode 100644 vivarium_tellurium/composites/injected_glc_phosphorylation.py delete mode 100644 vivarium_tellurium/experiments/test_tellurium_process.py diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 199656f..ace9d76 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8] + python-version: [3.10] steps: - uses: actions/checkout@v2 - name: Setup Python ${{ matrix.python-version }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b123bf7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.egg \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index d7ce44f..c3c83c6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,25 +15,4 @@ vivarium-core tellurium biosimulators-utils -numpy>=1.23 -scipy>=1.5.1 -matplotlib>=2.0.2 -pandas>=0.20.2 -libroadrunner>=2.1 -rrplugins>=2.1; platform_system == "Windows" -phrasedml>=1.0.9; (platform_machine != "arm64") -antimony>=2.12.0 -sbml2matlab>=0.9.1; (python_version < '3.10' and platform_machine != "arm64") -python-libsbml>=5.18.0 -python-libnuml>=1.0.0 -python-libsedml>=2.0.17 -python-libcombine>=0.2.2 -appdirs>=1.4.3 -jinja2>=3.0.0 -plotly>=2.0.12 -requests -jupyter-client>=5.1.0 -jupyter-core>=4.3.0 -ipython -ipykernel>=4.6.1 pytest \ No newline at end of file diff --git a/setup.py b/setup.py index 9ebe8e9..406a526 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ 'vivarium_tellurium.composites', 'vivarium_tellurium.experiments', ], - author='Alex Patrie, Eran Agmon', + author='Eran Agmon, Alexander Patrie', author_email='', url='https://github.com/vivarium-collective/vivarium-tellurium', license='', diff --git a/vivarium_tellurium.egg-info/PKG-INFO b/vivarium_tellurium.egg-info/PKG-INFO deleted file mode 100644 index 6d75da9..0000000 --- a/vivarium_tellurium.egg-info/PKG-INFO +++ /dev/null @@ -1,56 +0,0 @@ -Metadata-Version: 2.1 -Name: vivarium-tellurium -Version: 0.0.1 -Home-page: https://github.com/vivarium-collective/vivarium-tellurium -Author: Alex Patrie, Eran Agmon -Author-email: -Description-Content-Type: text/markdown - -# Template Vivarium Project - -Visit [the Vivarium Core -documentation](https://vivarium-core.readthedocs.io/) to learn how to -use the core Vivarium engine to create computational biology models. -Check out the -[getting started](https://vivarium-core.readthedocs.io/en/latest/getting_started.html) -guide of the documentation. - -## Using this Template -This repository contains a skeleton project you can build on to create -your own models. Go to the -[github page](https://github.com/vivarium-collective/vivarium-template) -and select `use this template`. - -What follows is a template `README.md`. - - - ------------------------------------------------------------------------- - -# Project Name - - - -Introduction to your project. - - - -## Installation - -Explain how users can get up and running. - - diff --git a/vivarium_tellurium.egg-info/SOURCES.txt b/vivarium_tellurium.egg-info/SOURCES.txt deleted file mode 100644 index 3b35f90..0000000 --- a/vivarium_tellurium.egg-info/SOURCES.txt +++ /dev/null @@ -1,14 +0,0 @@ -README.md -setup.py -vivarium_tellurium/__init__.py -vivarium_tellurium.egg-info/PKG-INFO -vivarium_tellurium.egg-info/SOURCES.txt -vivarium_tellurium.egg-info/dependency_links.txt -vivarium_tellurium.egg-info/requires.txt -vivarium_tellurium.egg-info/top_level.txt -vivarium_tellurium/composites/__init__.py -vivarium_tellurium/composites/injected_glc_phosphorylation.py -vivarium_tellurium/experiments/__init__.py -vivarium_tellurium/experiments/test_tellurium_process.py -vivarium_tellurium/processes/__init__.py -vivarium_tellurium/processes/tellurium_process.py \ No newline at end of file diff --git a/vivarium_tellurium.egg-info/dependency_links.txt b/vivarium_tellurium.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/vivarium_tellurium.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/vivarium_tellurium.egg-info/requires.txt b/vivarium_tellurium.egg-info/requires.txt deleted file mode 100644 index 41d4a6c..0000000 --- a/vivarium_tellurium.egg-info/requires.txt +++ /dev/null @@ -1,4 +0,0 @@ -tellurium -vivarium-core -biosimulators-utils -pytest diff --git a/vivarium_tellurium.egg-info/top_level.txt b/vivarium_tellurium.egg-info/top_level.txt deleted file mode 100644 index ae3ef46..0000000 --- a/vivarium_tellurium.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -vivarium_tellurium diff --git a/vivarium_tellurium/composites/injected_glc_phosphorylation.py b/vivarium_tellurium/composites/injected_glc_phosphorylation.py deleted file mode 100644 index c979e2d..0000000 --- a/vivarium_tellurium/composites/injected_glc_phosphorylation.py +++ /dev/null @@ -1,52 +0,0 @@ -""" -================================================ -Toy Injected Glucose Phosphorylation Compartment -================================================ - -This is a toy example referenced in the documentation. -""" - -# TODO: Delete this file before publishing your project. - -from vivarium.core.engine import Engine -from vivarium.core.composer import Composer - - -class InjectedGlcPhosphorylation(Composer): - - defaults = { - 'glucose_phosphorylation': { - 'k_cat': 1e-2, - }, - 'injector': { - 'substrate_rate_map': { - 'GLC': 1e-4, - 'ATP': 1e-3, - }, - }, - } - - def __init__(self, config): - super().__init__(config) - - def generate_processes(self, config): - '''injector = Injector(self.config['injector']) - glucose_phosphorylation = GlucosePhosphorylation( - self.config['glucose_phosphorylation']) - - return { - 'injector': injector, - 'glucose_phosphorylation': glucose_phosphorylation, - }''' - return None - - def generate_topology(self, config): - return { - 'injector': { - 'internal': ('cell', ), - }, - 'glucose_phosphorylation': { - 'cytoplasm': ('cell', ), - 'nucleoside_phosphates': ('cell', ), - }, - } diff --git a/vivarium_tellurium/experiments/test_tellurium_process.py b/vivarium_tellurium/experiments/test_tellurium_process.py deleted file mode 100644 index 7b6f863..0000000 --- a/vivarium_tellurium/experiments/test_tellurium_process.py +++ /dev/null @@ -1,44 +0,0 @@ -from vivarium.core.engine import Engine, pp -from vivarium_tellurium.processes.tellurium_process import TelluriumProcess - -""" -Test implementation file of a `TelluriumProcess` instance for Pytest. -""" - - -def test_tellurium(): - totaltime = 10.0 - - # initialize the process - config = {} - tellurium_process = TelluriumProcess(config) - - # declare the initial state, mirroring the ports structure - initial_state = { - 'internal': { - 'A': 0.0 - }, - 'external': { - 'A': 1.0 - }, - } - - ports = tellurium_process.ports_schema() - print('PORTS') - print(ports) - - # make the simulation - sim = Engine( - processes={'tellurium_process': tellurium_process}, - topology={'tellurium_process': {port_id: (port_id,) for port_id in ports.keys()}}, - initial_state=initial_state - ) - - # run the simulation - sim.update(totaltime) - - # get the results - data = sim.emitter.get_data() - - print(pp(data)) - diff --git a/vivarium_tellurium/processes/tellurium_process.py b/vivarium_tellurium/processes/tellurium_process.py index fb98e84..be0e6cd 100644 --- a/vivarium_tellurium/processes/tellurium_process.py +++ b/vivarium_tellurium/processes/tellurium_process.py @@ -74,3 +74,42 @@ def next_update(self, interval, states): +def test_tellurium(): + totaltime = 10.0 + + # initialize the process + config = {} + tellurium_process = TelluriumProcess(config) + + # declare the initial state, mirroring the ports structure + initial_state = { + 'internal': { + 'A': 0.0 + }, + 'external': { + 'A': 1.0 + }, + } + + ports = tellurium_process.ports_schema() + print('PORTS') + print(ports) + + # make the simulation + sim = Engine( + processes={'tellurium_process': tellurium_process}, + topology={'tellurium_process': {port_id: (port_id,) for port_id in ports.keys()}}, + initial_state=initial_state + ) + + # run the simulation + sim.update(totaltime) + + # get the results + data = sim.emitter.get_data() + + print(pp(data)) + + +if __name__ == '__main__': + test_tellurium() \ No newline at end of file From ee79daa704b1bd6ebefdbc495b6035d9ab338717 Mon Sep 17 00:00:00 2001 From: alex patrie Date: Fri, 21 Jul 2023 17:07:14 -0400 Subject: [PATCH 09/18] feat: implemented test antimony instance --- .../processes/tellurium_process.py | 103 +++++++++++++++++- 1 file changed, 101 insertions(+), 2 deletions(-) diff --git a/vivarium_tellurium/processes/tellurium_process.py b/vivarium_tellurium/processes/tellurium_process.py index be0e6cd..dfc6d2d 100644 --- a/vivarium_tellurium/processes/tellurium_process.py +++ b/vivarium_tellurium/processes/tellurium_process.py @@ -1,4 +1,6 @@ import json +from typing import Union +import importlib import tellurium as te from vivarium.core.process import Process from vivarium.core.engine import Engine, pp @@ -9,8 +11,8 @@ class TelluriumProcess(Process): # declare default parameters as class variables defaults = { + 'api': 'tellurium', 'model_path': '', - 'uptake_rate': 0.1, } def __init__(self, parameters=None): @@ -72,9 +74,106 @@ def next_update(self, interval, states): return update +class AntimonyTelluriumProcess(TelluriumProcess): + + defaults = { + 'api': 'tellurium', + 'api_imports': ('loada'), + 'antimony_string': '', + } + + def __init__(self, parameters=None): + #instantiate the parent + super().__init__(parameters) + + #get the tellurium package as an object + tellurium = importlib.import_module(self.parameters['api']) + + #traverse the parameters to extract the package imports needed + for content in self.parameters['api_imports']: + self.__setattr__(content, getattr(tellurium, content)) + + + def next_update(self, interval, states, n_timesteps=100, antimony_string=None): + # get the states from the tellurium model + internal_A = states['internal']['A'] + external_A = states['external']['A'] + + # run tellurium here + antimony_string = antimony_string or self.parameters['antimony_string'] + internal_update = self.loada(antimony_string).simulate(0, interval, n_timesteps) + external_update = -1 * internal_update + + # get the results from tellurium + update = { + 'internal': { + 'A': internal_update}, + 'external': { + 'A': external_update} + } + # return an update that mirrors the ports structure + return update + + + +def test_process(process: Union[TelluriumProcess, AntimonyTelluriumProcess], + process_name: str, + initial_state: dict, + total_time: float, + config: dict = {}): + proc = process(config) + ports = proc.ports_schema() + sim = Engine( + processes={process_name: proc}, + topology={process_name: {port_id: (port_id,) for port_id in ports.keys()}}, + initial_state=initial_state + ) + sim.update(total_time) + return sim.emitter.get_data() + def test_tellurium(): + config = {} + process = TelluriumProcess(config) + name = 'tellurium' + initial_state = { + 'internal': { + 'A': 0.0 + }, + 'external': { + 'A': 1.0 + }, + } + data = test_process(process, name, initial_state, 10.0, config) + pp(data) + +def test_antimony(): + config = {} + process = AntimonyTelluriumProcess(config) + process.parameters['antimony_string'] = 'S1 -> S2; k1*S1; k1 = 0.1; S1 = 10' + config['antimony_string'] = 'S1 -> S2; k1*S1; k1 = 0.1; S1 = 10' + name = 'antimony' + initial_state = { + 'internal': { + 'A': 0.0 + }, + 'external': { + 'A': 1.0 + }, + } + ports = process.ports_schema() + sim = Engine( + processes={name: process}, + topology={name: {port_id: (port_id,) for port_id in ports.keys()}}, + initial_state=initial_state + ) + sim.update(10.0) + data = sim.emitter.get_data() + pp(data) + + +def __test_tellurium(): totaltime = 10.0 # initialize the process @@ -112,4 +211,4 @@ def test_tellurium(): if __name__ == '__main__': - test_tellurium() \ No newline at end of file + test_antimony() \ No newline at end of file From b8f617532467c181c088a8406623bd6aeca9e5d6 Mon Sep 17 00:00:00 2001 From: alex patrie Date: Mon, 24 Jul 2023 12:56:46 -0400 Subject: [PATCH 10/18] feat: minor adjustments to Tellurium imports in class --- vivarium_tellurium/processes/requirements.txt | 2 ++ .../processes/tellurium_process.py | 21 ++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 vivarium_tellurium/processes/requirements.txt diff --git a/vivarium_tellurium/processes/requirements.txt b/vivarium_tellurium/processes/requirements.txt new file mode 100644 index 0000000..f18fbc0 --- /dev/null +++ b/vivarium_tellurium/processes/requirements.txt @@ -0,0 +1,2 @@ +numpy +pandas diff --git a/vivarium_tellurium/processes/tellurium_process.py b/vivarium_tellurium/processes/tellurium_process.py index dfc6d2d..1f92916 100644 --- a/vivarium_tellurium/processes/tellurium_process.py +++ b/vivarium_tellurium/processes/tellurium_process.py @@ -1,6 +1,6 @@ import json from typing import Union -import importlib +from importlib import import_module import tellurium as te from vivarium.core.process import Process from vivarium.core.engine import Engine, pp @@ -12,13 +12,28 @@ class TelluriumProcess(Process): # declare default parameters as class variables defaults = { 'api': 'tellurium', + 'api_imports': [], 'model_path': '', } def __init__(self, parameters=None): - # parameters passed into the constructor merge with the defaults - # and can be access through the self.parameters class variable + ''' + A generic instance: Tellurium implementation of the `vivarium.core.processes.Process()` interface. + + Parameters passed into the constructor merge with the defaults and can be accessed through the `self.parameters` class attribute. + + #### Parameters: + ---------------- + parameters:`Dict` + default setting parameters for this Tellurium instance. Defaults to`None`. + ''' super().__init__(parameters) + + # import the necessary simulator api + module = import_module(self.parameters['api']) + # set the appropriate values from the given api content + for content in self.parameters['api_imports']: + self.__setattr__(content, getattr(module, content)) def ports_schema(self): ''' From e5c8320e6b4bb922b2b31527ee03fbeca562fa10 Mon Sep 17 00:00:00 2001 From: alex patrie Date: Mon, 24 Jul 2023 14:29:26 -0400 Subject: [PATCH 11/18] feat: readjusted setup implementation based on update template repo --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 4 +- requirements.txt | 5 +- setup.py | 27 ++- vivarium_tellurium/.DS_Store | Bin 0 -> 6148 bytes .../composites/template_composite.py | 113 +++++++++ vivarium_tellurium/processes/requirements.txt | 2 - .../processes/tellurium_process.py | 214 +++++------------- 8 files changed, 191 insertions(+), 174 deletions(-) create mode 100644 .DS_Store create mode 100644 vivarium_tellurium/.DS_Store create mode 100644 vivarium_tellurium/composites/template_composite.py delete mode 100644 vivarium_tellurium/processes/requirements.txt diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d5642bfdecb4819b37bbf078fcd2a53019b3ba1a GIT binary patch literal 6148 zcmeHKJ5Iwu5S@V(mM9WYQLbpHLqoen<^(wa5P}HEmZJ!#pz@)(0{7z0Cny#!A_|1i zjJ5k_XJ_{FB=7DJ5zpG?lxRXk1&SbxG9Y3e>^gGi5s-C^4Lws!HQmzdz(9Y|Bx^sV zE!MrId)io$W0yaUU9a}n zn=xfbFc1s`1HnKrpbX&77AZ~)qYegwfneZ^0XZKMiePr^4E5+hr6~YVp3y4MC6|zx zxKg>`m}pVXZ=8%7-r1Ot5rj;%S7 z`~L>N%wUq=4~bSV5Dfe?26$A?%NaK1ck8$9$z7XJ?odR;uM-6Vz4r(}L(Y*i?X>cBi!ud8X4tuMK?49T9^ao zz+ZQOzug{9D5I2?sO9&&m=8viEM4jYgsV1QnkC72k&SUaczb_5emHqPZRbvZ&0Str z@6R$R#Jq9`l`~plmPvuvm}~O7QYN-Bt6KZP)2G&!>!#US?a%DGUQw}23+Nm}?FI6_ zLFX4nRo}~gsc(a|*455x(6a~cR(Qt~nV)m6bxjAa(A~hQ>gpVpx*C~lZQnEN`sDqJ zX;!x80M=}dAXKz!4wwVxKJIGa&pxmJXYKp{ zdXxP!2h4$g<$&uZqhyFj@@wnH!|_@hA Date: Mon, 24 Jul 2023 14:41:33 -0400 Subject: [PATCH 12/18] fix: updated pytest yaml file for python versions --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index ace9d76..79742ce 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.10] + python-version: ['3.8', '3.9', '3.10'] steps: - uses: actions/checkout@v2 - name: Setup Python ${{ matrix.python-version }} From af8c5aba069ec7328bf7e623f73940f4f44193ae Mon Sep 17 00:00:00 2001 From: alex patrie Date: Mon, 24 Jul 2023 14:49:27 -0400 Subject: [PATCH 13/18] fix: adjusted absolute import declaration to corrected --- vivarium_tellurium/composites/template_composite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vivarium_tellurium/composites/template_composite.py b/vivarium_tellurium/composites/template_composite.py index e609ec1..b964223 100644 --- a/vivarium_tellurium/composites/template_composite.py +++ b/vivarium_tellurium/composites/template_composite.py @@ -13,7 +13,7 @@ from vivarium.library.pretty import format_dict from vivarium.processes.injector import Injector -from template.processes.template_process import Template +from vivarium_tellurium.processes.tellurium_process import Template class TemplateComposer(Composer): From c63ea4052a7e35deb273cb3cc2cae755bc55b996 Mon Sep 17 00:00:00 2001 From: alex patrie Date: Mon, 24 Jul 2023 15:03:19 -0400 Subject: [PATCH 14/18] fix: removed pytest install from yaml and added it to requirements --- .github/workflows/pytest.yml | 1 - requirements.txt | 3 ++- setup.py | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 79742ce..fd3adbf 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -24,7 +24,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Test with pytest run: | diff --git a/requirements.txt b/requirements.txt index 128d174..38b379f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,4 +12,5 @@ # vivarium-core -tellurium \ No newline at end of file +tellurium +pytest \ No newline at end of file diff --git a/setup.py b/setup.py index 2cb5dc6..4ccb030 100644 --- a/setup.py +++ b/setup.py @@ -20,8 +20,6 @@ author_email='', url='https://github.com/vivarium-collective/vivarium-tellurium', license='', - entry_points={ - 'console_scripts': []}, short_description='A Vivarium interface for Tellurium', long_description=long_description, long_description_content_type='text/markdown', From fc6f7b4ba66fe4b7cfa9ad087a2ddd142bbfedac Mon Sep 17 00:00:00 2001 From: alex patrie Date: Mon, 24 Jul 2023 15:11:32 -0400 Subject: [PATCH 15/18] fix: changed dep to setuptools in the setup file --- setup.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 4ccb030..0854221 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,5 @@ # import os -# import glob -# import setuptools -from distutils.core import setup +from setuptools import setup with open("README.md", 'r') as readme: long_description = readme.read() @@ -20,14 +18,13 @@ author_email='', url='https://github.com/vivarium-collective/vivarium-tellurium', license='', - short_description='A Vivarium interface for Tellurium', + description='A Vivarium interface for Tellurium', long_description=long_description, long_description_content_type='text/markdown', - package_data={}, include_package_data=True, install_requires=[ 'vivarium-core', 'tellurium', 'pytest', ], -) +) \ No newline at end of file From 57aa22aaa4c1586db1d69d3f41ba9d1ed59439bf Mon Sep 17 00:00:00 2001 From: alex patrie Date: Mon, 24 Jul 2023 15:14:42 -0400 Subject: [PATCH 16/18] removed older python versions from pytest --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index fd3adbf..ebe17d9 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8', '3.9', '3.10'] + python-version: ['3.10'] steps: - uses: actions/checkout@v2 - name: Setup Python ${{ matrix.python-version }} From 9a1665655c8d9612228d133b4656250bd880ea5a Mon Sep 17 00:00:00 2001 From: alex patrie Date: Mon, 24 Jul 2023 15:20:25 -0400 Subject: [PATCH 17/18] fix: adjusted run statement in pytest file --- .github/workflows/pytest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index ebe17d9..8e11c3e 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -24,7 +24,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + if [ -f requirements.txt ]; then pip install -r requirements.txt; else pip install -e .; fi - name: Test with pytest run: | - pytest + pytest -v From ef75b7a75f44350ca9624650b5e6fe903a13a8cf Mon Sep 17 00:00:00 2001 From: alex patrie Date: Mon, 24 Jul 2023 15:22:13 -0400 Subject: [PATCH 18/18] fix: removed template name in place of module name in pytest ini file --- pytest.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index 0d1dd09..316dbc3 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,6 +2,6 @@ python_files = *.py addopts = --doctest-modules --strict-markers # TODO: Replace `template` when you change the folder name. -testpaths = template +testpaths = vivarium_tellurium markers = slow: indicates slow tests (deselect with '-m "not slow"')