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

Commit

Permalink
updated utils generator
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Feb 28, 2024
1 parent 501693c commit f2b711c
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 42 deletions.
44 changes: 7 additions & 37 deletions biosimulator_processes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ def generate_emitter_schema(
'_type': 'step',
'address': 'local:ram-emitter',
'config': {
'emit': {
'floating_species': 'tree[float]',
'time': 'float',
},
'emit': {**emit_values_schema},
},
'inputs': {
'inputs': { # TODO: make this generalized
'floating_species': ['floating_species_store'],
'time': ['time_store'],
}
Expand All @@ -73,7 +70,8 @@ def generate_composite_copasi_process_instance(instance_name: str, config: Dict,
Args:
instance_name:`str`: name of the new instance referenced by PBG.
config:`Dict`: see `biosimulator_processes.processes.copasi_process.CopasiProcess`
add_emitter:`
add_emitter:`bool`: Adds emitter schema configured for CopasiProcess IO store if `True`. Defaults
to `True`.
"""
instance = {}
instance[instance_name] = {
Expand All @@ -91,38 +89,10 @@ def generate_composite_copasi_process_instance(instance_name: str, config: Dict,
'time': ['time_store'],
}
}
if add_emitter:
instance['emitter'] = generate_copasi_process_emitter_schema()

return {
instance_name: {
'_type': 'process',
'address': 'local:copasi',
'config': config,
'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'],
}
}
}
return instance



82 changes: 77 additions & 5 deletions notebooks/copasi_process_composer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"id": "initial_id",
"metadata": {
"ExecuteTime": {
"end_time": "2024-02-28T21:35:30.970032Z",
"start_time": "2024-02-28T21:35:30.965409Z"
"end_time": "2024-02-28T22:21:50.630537Z",
"start_time": "2024-02-28T22:21:50.627788Z"
}
},
"outputs": [],
Expand All @@ -34,8 +34,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-28T21:35:36.900035Z",
"start_time": "2024-02-28T21:35:34.590082Z"
"end_time": "2024-02-28T22:21:52.425406Z",
"start_time": "2024-02-28T22:21:50.700424Z"
}
},
"outputs": [
Expand Down Expand Up @@ -475,14 +475,86 @@
"id": "3b8a27c7dd246d02",
"execution_count": 1
},
{
"cell_type": "code",
"outputs": [],
"source": [
"from biosimulator_processes.utils import generate_composite_copasi_process_instance as copasi_instance"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-28T22:25:33.366994Z",
"start_time": "2024-02-28T22:25:32.646371Z"
}
},
"id": "57712e54678bcb70",
"execution_count": 1
},
{
"cell_type": "code",
"outputs": [],
"source": [
"model_config = {\n",
" 'model': {\n",
" 'model_changes': {\n",
" 'reaction_changes': {\n",
" 'R1': 'A -> B'\n",
" }\n",
" }\n",
" }\n",
"}\n",
"\n",
"\n",
"instance = copasi_instance(\n",
" instance_name='copasi_A',\n",
" config=model_config,\n",
" add_emitter=True\n",
")"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-28T22:25:51.771960Z",
"start_time": "2024-02-28T22:25:51.763524Z"
}
},
"id": "482579fdd5bb4350",
"execution_count": 2
},
{
"cell_type": "code",
"outputs": [
{
"data": {
"text/plain": "{'copasi_A': {'_type': 'process',\n 'address': 'local:copasi',\n 'config': {'model': {'model_changes': {'reaction_changes': {'R1': 'A -> B'}}}},\n 'inputs': {'floating_species': ['floating_species_store'],\n 'model_parameters': ['model_parameters_store'],\n 'time': ['time_store'],\n 'reactions': ['reactions_store']},\n 'outputs': {'floating_species': ['floating_species_store'],\n 'time': ['time_store']}},\n 'emitter': {'_type': 'step',\n 'address': 'local:ram-emitter',\n 'config': {'emit': {'floating_species': 'tree[float]', 'time': 'float'}},\n 'inputs': {'floating_species': ['floating_species_store'],\n 'time': ['time_store']}}}"
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"instance"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-28T22:25:53.779628Z",
"start_time": "2024-02-28T22:25:53.774909Z"
}
},
"id": "9e11e97613ec9e16",
"execution_count": 3
},
{
"cell_type": "code",
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
},
"id": "57712e54678bcb70"
"id": "1ecc10e496abe9cb"
}
],
"metadata": {
Expand Down

0 comments on commit f2b711c

Please sign in to comment.