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

Commit

Permalink
updated process for copasi notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Feb 28, 2024
1 parent 7860754 commit 4849843
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 29 deletions.
64 changes: 48 additions & 16 deletions biosimulator_processes/processes/copasi_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@
run_time_course,
get_compartments,
new_model,
add_reaction
add_reaction,
T,
set_report_dict
)
from process_bigraph import Process, Composite, pf
from biosimulator_processes.utils import fetch_biomodel
from biosimulator_processes.process_types import MODEL_TYPE
import biosimulator_processes.processes


class CopasiProcess(Process):
Expand Down Expand Up @@ -166,6 +169,7 @@ def __init__(self, config=None, core=None):
self.compartments_list = get_compartments(model=self.copasi_model_object).index.tolist()

self.method = self.config.get('method')
# set_report_dict('Time-Course', task=T.TIME_COURSE, model=self.copasi_model_object, body=['Time'])

def initial_state(self):
floating_species_dict = dict(
Expand Down Expand Up @@ -215,24 +219,12 @@ def update(self, inputs, interval):
model=self.copasi_model_object)

# run model for "interval" length; we only want the state at the end
timecourse_args = {
'start_time': inputs['time'],
'duration': interval,
'update_model': True,
# 'intervals': 1,
'model': self.copasi_model_object}

if self.method is not None:
timecourse_args['method'] = self.method

# run the time course with given kwargs
# timecourse = run_time_course(**timecourse_args)
timecourse = run_time_course(
start_time=inputs['time'],
duration=interval,
update_model=True,
model=self.copasi_model_object
)
model=self.copasi_model_object,
method=self.method)

# extract end values of concentrations from the model and set them in results
results = {'time': interval}
Expand Down Expand Up @@ -284,10 +276,50 @@ def test_process():
}
}

instance = {
'copasi': {
'_type': 'process',
'address': 'local:copasi',
'config': {
'model': {
'model_source': 'biosimulator_processes/model_files/Caravagna2010.xml'
}
},
'inputs': {
'floating_species': ['floating_species_store'],
'model_parameters': ['model_parameters_store'],
'time': ['time_store'],
'reactions': ['reactions_store']
},
'outputs': {
'floating_species': ['floating_species_store'],
'time': ['time_store'],
}
},
'emitter': {
'_type': 'step',
'address': 'local:ram-emitter',
'config': {
'emit': {
'floating_species': 'tree[float]',
'time': 'float',
},
},
'inputs': {
'floating_species': ['floating_species_store'],
'time': ['time_store'],
}
}
}

workflow = Composite({
'state': initial_sim_state
'state': instance # initial_sim_state
})
workflow.run(10)
results = workflow.gather_results()
print(f'RESULTS: {pf(results)}')
assert ('emitter',) in results.keys(), "This instance was not properly configured with an emitter."


if __name__ == "__main__":
test_process()
40 changes: 27 additions & 13 deletions notebooks/copasi_process_composer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -174,31 +174,33 @@
"source": [
"workflow = Composite({\n",
" 'state': instance\n",
"})"
]
},
{
"cell_type": "markdown",
"id": "6a402e48fbc30a5b",
"metadata": {
"collapsed": false
},
"source": [
"##### 3. Run the Composite workflow with the Engine"
"})\n",
"\n",
"# basico.set_report_dict('composite_process_model', task=T.TIME_COURSE)\n"
]
},
{
"cell_type": "code",
"outputs": [],
"source": [
"workflow.config_schema"
"basico.T.TIME_COURSE"
],
"metadata": {
"collapsed": false
},
"id": "9d5477c224adfa39",
"id": "5690cd2793a5a53b",
"execution_count": null
},
{
"cell_type": "markdown",
"id": "6a402e48fbc30a5b",
"metadata": {
"collapsed": false
},
"source": [
"##### 3. Run the Composite workflow with the Engine"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -211,6 +213,18 @@
"workflow.run(10)"
]
},
{
"cell_type": "code",
"outputs": [],
"source": [
"workflow.process_paths"
],
"metadata": {
"collapsed": false
},
"id": "92246d0c4cdc0e51",
"execution_count": null
},
{
"cell_type": "markdown",
"id": "d0ff3a2822a8fa2c",
Expand Down

0 comments on commit 4849843

Please sign in to comment.