Skip to content

Commit

Permalink
updated workflows for fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Mar 12, 2024
1 parent 5174e49 commit c677209
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 27 deletions.
2 changes: 1 addition & 1 deletion biosimulator_processes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
PROCESSES_TO_REGISTER = [
('cobra', 'cobra_process.CobraProcess'),
('copasi', 'copasi_process.CopasiProcess'),
# ('smoldyn', 'smoldyn_process.SmoldynProcess'),
('smoldyn', 'smoldyn_process.SmoldynProcess'),
('tellurium', 'tellurium_process.TelluriumProcess'),
('parameter_scan', 'parameter_scan.DeterministicTimeCourseParameterScan')
]
Expand Down
Binary file not shown.
Binary file not shown.
15 changes: 8 additions & 7 deletions biosimulator_processes/processes/cobra_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,11 @@ def update(self, inputs, interval):


def test_process():
CORE.process_registry.register('biosimulator_processes.processes.cobra_process.CobraProcess', CobraProcess)
instance = {
'fba': {
'_type': 'process',
'address': 'local:cobra', # TODO 'biosimulators:cobra[1.0]',
'address': 'local:!biosimulator_processes.processes.cobra_process.CobraProcess',
'config': {
'model_file': 'biosimulator_processes/model_files/e_coli_core.xml'
},
Expand All @@ -146,13 +147,13 @@ def test_process():
}

# make the composite
workflow = Composite({
'state': instance
})
# workflow = Composite({
# 'state': instance
# })

# run
workflow.run(1)
# workflow.run(1)

# gather results
results = workflow.gather_results()
print(f'RESULTS: {pf(results)}')
# results = workflow.gather_results()
# print(f'RESULTS: {pf(results)}')
5 changes: 3 additions & 2 deletions biosimulator_processes/processes/copasi_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,11 @@ def update(self, inputs, interval):


def test_process():
CORE.process_registry.register('biosimulator_processes.processes.copasi_process.CopasiProcess', CopasiProcess)
instance = {
'copasi': {
'_type': 'process',
'address': 'local:copasi',
'address': 'local:!biosimulator_processes.processes.copasi_process.CopasiProcess',
'config': {
'model': {
'model_source': {
Expand Down Expand Up @@ -309,7 +310,7 @@ def test_process():

workflow = Composite(config={
'state': instance # initial_sim_state
}, core=CORE)
})
workflow.run(10)
results = workflow.gather_results()
print(f'RESULTS: {pf(results)}')
Expand Down
16 changes: 9 additions & 7 deletions biosimulator_processes/processes/smoldyn_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def test_connect():
from typing import *
from uuid import uuid4
from process_bigraph import Process, Composite, pf, pp
from biosimulator_processes import CORE
try:
import smoldyn as sm
from smoldyn._smoldyn import MolecState
Expand Down Expand Up @@ -340,10 +341,11 @@ def test_process():

# this is the instance for the composite process to run
print("RUNNING")
CORE.process_registry.register('biosimulator_processes.processes.smoldyn_process.SmoldynProcess', SmoldynProcess)
instance = {
'smoldyn': {
'_type': 'process',
'address': 'local:smoldyn',
'address': 'local:!biosimulator_processes.processes.smoldyn_process.SmoldynProcess',
'config': {
'model_filepath': 'biosimulator_processes/model_files/minE_model.txt',
'animate': False},
Expand Down Expand Up @@ -371,13 +373,13 @@ def test_process():
total_time = 2

# make the composite
workflow = Composite({
'state': instance
})
# workflow = Composite({
# 'state': instance
# })

# run
workflow.run(total_time)
# workflow.run(total_time)

# gather results
results = workflow.gather_results()
pp(f'RESULTS: {pf(results)}')
# results = workflow.gather_results()
# pp(f'RESULTS: {pf(results)}')
17 changes: 8 additions & 9 deletions biosimulator_processes/processes/tellurium_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as np
import tellurium as te
from process_bigraph import Process, Composite, pf, Step
from biosimulator_processes import CORE


class TelluriumStep(Step):
Expand Down Expand Up @@ -88,8 +89,8 @@ class TelluriumProcess(Process):
'record_history': 'bool', # TODO -- do we have this type?
}

def __init__(self, config=None):
super().__init__(config)
def __init__(self, config=None, core=None):
super().__init__(config, core)

# initialize a tellurium(roadrunner) simulation object. Load the model in using either sbml(default) or antimony
if self.config.get('antimony_string') and not self.config.get('sbml_model_path'):
Expand Down Expand Up @@ -185,13 +186,11 @@ def update(self, inputs, interval):

def test_process():
# 1. define the instance of the Composite(in this case singular) by its schema
CORE.process_registry.register('biosimulator_processes.processes.tellurium_process.TelluriumProcess', TelluriumProcess)
instance = {
# 'start_time_store': 0,
# 'run_time_store': 1,
# 'results_store': None, # TODO -- why is this not automatically added into the schema because of tellurium schema?
'tellurium': {
'_type': 'process',
'address': 'local:tellurium', # using a local toy process
'address': 'local:!biosimulator_processes.processes.tellurium_process.TelluriumProcess', # using a local toy process
'config': {
'sbml_model_path': 'biosimulator_processes/model_files/BIOMD0000000061_url.xml',
},
Expand All @@ -216,8 +215,8 @@ def test_process():
})

# 3. run
update = workflow.run(10)
# update = workflow.run(10)

# 4. gather results
results = workflow.gather_results()
print(f'RESULTS: {pf(results)}')
# results = workflow.gather_results()
# print(f'RESULTS: {pf(results)}')
50 changes: 49 additions & 1 deletion notebooks/playground.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,56 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "62767f2206188000",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-12T17:37:36.385928Z",
"start_time": "2024-03-12T17:37:36.379752Z"
},
"collapsed": false
},
"outputs": [],
"source": [
"from biosimulator_processes import CORE"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "7ad30f8917b149d5",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-12T17:37:41.103600Z",
"start_time": "2024-03-12T17:37:41.100576Z"
},
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{'console-emitter': process_bigraph.composite.ConsoleEmitter,\n",
" 'ram-emitter': process_bigraph.composite.RAMEmitter,\n",
" 'CobraProcess': biosimulator_processes.processes.cobra_process.CobraProcess,\n",
" 'CopasiProcess': biosimulator_processes.processes.copasi_process.CopasiProcess,\n",
" 'TelluriumProcess': biosimulator_processes.processes.tellurium_process.TelluriumProcess,\n",
" 'DeterministicTimeCourseParameterScan': biosimulator_processes.steps.parameter_scan.DeterministicTimeCourseParameterScan}"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"CORE.process_registry.registry"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "171fba34f47ded38",
"metadata": {
"collapsed": false
},
Expand Down

0 comments on commit c677209

Please sign in to comment.