Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
feat: implemented builder adjusted scripts for new smoldyn and updated l
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Feb 29, 2024
1 parent 32a0192 commit c57e576
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 130 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& pip install --upgrade pip && pip install poetry \
&& poetry config virtualenvs.in-project true \
# && poetry run pip install psutil \
&& poetry update \
&& poetry install \
&& chmod +x ./trust-notebooks.sh \
&& ./trust-notebooks.sh \
Expand Down
11 changes: 7 additions & 4 deletions biosimulator_processes/processes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from process_bigraph import process_registry
from builder import ProcessTypes, Builder


# Define a list of processes to attempt to import and register
processes_to_register = [
PROCESSES_TO_REGISTER = [
('cobra', 'cobra_process.CobraProcess'),
('copasi', 'copasi_process.CopasiProcess'),
('smoldyn', 'smoldyn_process.SmoldynProcess'),
('tellurium', 'tellurium_process.TelluriumProcess'),
]

for process_name, process_path in processes_to_register:
CORE = ProcessTypes()
BIOSIMULATOR_PROCESS_BUILDER = Builder(core=CORE)

for process_name, process_path in PROCESSES_TO_REGISTER:
module_name, class_name = process_path.rsplit('.', 1)
try:
# Dynamically import the module
Expand All @@ -19,7 +22,7 @@
process_class = getattr(process_module, class_name)

# Register the process
process_registry.register(process_name, process_class)
BIOSIMULATOR_PROCESS_BUILDER.register_process(process_name, process_class)
print(f"{class_name} registered successfully.")
except ImportError as e:
print(f"{class_name} not available. Error: {e}")
116 changes: 28 additions & 88 deletions notebooks/copasi_process_composer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "initial_id",
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2024-02-29T19:54:21.729902Z",
"start_time": "2024-02-29T19:54:21.723041Z"
}
},
"outputs": [],
"source": [
"import sys \n",
Expand All @@ -24,16 +29,34 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "c6c10dc5988e52d4",
"metadata": {
"collapsed": false
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-29T19:54:23.693482Z",
"start_time": "2024-02-29T19:54:22.908092Z"
}
},
"outputs": [],
"outputs": [
{
"ename": "ImportError",
"evalue": "cannot import name 'process_registry' from 'process_bigraph' (/Users/alex/Library/Caches/pypoetry/virtualenvs/biosimulator-processes-KVuYbFzt-py3.10/lib/python3.10/site-packages/process_bigraph/__init__.py)",
"output_type": "error",
"traceback": [
"\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
"\u001B[0;31mImportError\u001B[0m Traceback (most recent call last)",
"Cell \u001B[0;32mIn[2], line 5\u001B[0m\n\u001B[1;32m 3\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mprocess_bigraph\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m Composite, pf \n\u001B[1;32m 4\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mbuilder\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m Builder, Process \u001B[38;5;28;01mas\u001B[39;00m builderProcess, ProcessTypes\n\u001B[0;32m----> 5\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mbiosimulator_processes\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mprocesses\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mcopasi_process\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m CopasiProcess\n\u001B[1;32m 6\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mbiosimulator_processes\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mprocess_types\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m MODEL_TYPE, CHANGES_SCHEMA\n\u001B[1;32m 7\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mbiosimulator_processes\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mutils\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m play_composition\n",
"File \u001B[0;32m~/Desktop/uchc_work/biosimulator-processes/notebooks/../biosimulator_processes/processes/__init__.py:1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mprocess_bigraph\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m process_registry\n\u001B[1;32m 4\u001B[0m \u001B[38;5;66;03m# Define a list of processes to attempt to import and register\u001B[39;00m\n\u001B[1;32m 5\u001B[0m processes_to_register \u001B[38;5;241m=\u001B[39m [\n\u001B[1;32m 6\u001B[0m (\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mcobra\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mcobra_process.CobraProcess\u001B[39m\u001B[38;5;124m'\u001B[39m),\n\u001B[1;32m 7\u001B[0m (\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mcopasi\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mcopasi_process.CopasiProcess\u001B[39m\u001B[38;5;124m'\u001B[39m),\n\u001B[1;32m 8\u001B[0m (\u001B[38;5;124m'\u001B[39m\u001B[38;5;124msmoldyn\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124msmoldyn_process.SmoldynProcess\u001B[39m\u001B[38;5;124m'\u001B[39m),\n\u001B[1;32m 9\u001B[0m (\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mtellurium\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mtellurium_process.TelluriumProcess\u001B[39m\u001B[38;5;124m'\u001B[39m),\n\u001B[1;32m 10\u001B[0m ]\n",
"\u001B[0;31mImportError\u001B[0m: cannot import name 'process_registry' from 'process_bigraph' (/Users/alex/Library/Caches/pypoetry/virtualenvs/biosimulator-processes-KVuYbFzt-py3.10/lib/python3.10/site-packages/process_bigraph/__init__.py)"
]
}
],
"source": [
"import os \n",
"from basico import *\n",
"from process_bigraph import Composite, pf \n",
"from builder import Builder, Process as builderProcess, ProcessTypes\n",
"from biosimulator_processes.processes.copasi_process import CopasiProcess\n",
"from biosimulator_processes.process_types import MODEL_TYPE, CHANGES_SCHEMA\n",
"from biosimulator_processes.utils import play_composition"
Expand Down Expand Up @@ -269,67 +292,6 @@
"id": "433d58bbe38402af",
"execution_count": null
},
{
"cell_type": "code",
"outputs": [],
"source": [
"instance2 = {\n",
" 'copasi': {\n",
" '_type': 'process',\n",
" 'address': 'local:copasi',\n",
" 'config': {\n",
" 'model': {\n",
" 'model_changes': {\n",
" 'reaction_changes': {\n",
" 'R1': 'A -> B'\n",
" }\n",
" }\n",
" }\n",
" },\n",
" 'inputs': {\n",
" 'floating_species': ['floating_species_store'],\n",
" 'model_parameters': ['model_parameters_store'],\n",
" 'time': ['time_store'],\n",
" 'reactions': ['reactions_store']\n",
" },\n",
" 'outputs': {\n",
" 'floating_species': ['floating_species_store'],\n",
" 'time': ['time_store'],\n",
" }\n",
" },\n",
" 'emitter': {\n",
" '_type': 'step',\n",
" 'address': 'local:ram-emitter',\n",
" 'config': {\n",
" 'emit': {\n",
" 'floating_species': 'tree[float]',\n",
" 'time': 'float',\n",
" },\n",
" },\n",
" 'inputs': {\n",
" 'floating_species': ['floating_species_store'],\n",
" 'time': ['time_store'],\n",
" }\n",
" }\n",
"}\n",
"\n",
"\n",
"results = play_composition(instance2, 10)"
],
"metadata": {
"collapsed": false
},
"id": "8178d3c295764eb6",
"execution_count": null
},
{
"cell_type": "code",
"execution_count": null,
"id": "1a51b92b-35af-4d94-b9d5-97da90cfa5bd",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"source": [
Expand Down Expand Up @@ -364,28 +326,6 @@
"id": "1ecc10e496abe9cb",
"execution_count": null
},
{
"cell_type": "code",
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
},
"id": "35ea2649d0f98801",
"execution_count": null
},
{
"cell_type": "code",
"outputs": [],
"source": [
"results = play_composition(instance=parameter_scan_instance, duration=10)"
],
"metadata": {
"collapsed": false
},
"id": "87cced9f87885d4e",
"execution_count": null
},
{
"cell_type": "code",
"outputs": [],
Expand Down
82 changes: 48 additions & 34 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ numpy = "*" # "^1.26.4"
copasi-basico = "*"
cobra = "*"
tellurium = "*"
smoldyn = "*"
bigraph-viz = "^0.0.31"
smoldyn = ">=2.72"
bigraph-viz = ">=0.0.31"
bigraph-builder = ">=0.0.4"
python-libsbml = "^5.20.2"
docker = ">=7.0"
python-libnuml = "^1.1.6" # ">=1.0.0"
notebook = "^7.1.1"
# psutil = "^5.9.8"

[tool.poetry.group.dev.dependencies]
pytest = "*"
Expand Down
4 changes: 2 additions & 2 deletions scripts/install-smoldyn-mac-silicon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# The following script serves as a utility for installing this repository with the Smoldyn requirement on a Silicon Mac

# set installation parameters
dist_url=https://www.smoldyn.org/smoldyn-2.72-mac.tgz
tarball_name=smoldyn-2.72-mac.tgz
dist_url=https://www.smoldyn.org/smoldyn-2.73-mac.tgz
tarball_name=smoldyn-2.73-mac.tgz
dist_dir=${tarball_name%.tgz}

# uninstall existing version
Expand Down

0 comments on commit c57e576

Please sign in to comment.