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

Commit

Permalink
adjusted reaction in example for copasi
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Feb 28, 2024
1 parent 4849843 commit 27f17e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 39 deletions.
19 changes: 8 additions & 11 deletions biosimulator_processes/processes/copasi_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


from typing import Dict
from pandas import DataFrame
from basico import (
load_model,
get_species,
Expand Down Expand Up @@ -111,7 +112,7 @@ class CopasiProcess(Process):
config_schema = {
'model': MODEL_TYPE,
'biomodel_id': 'maybe[string]', # <-- implies the lack of either model_file or model_reactions
'units': 'maybe[tree[string]]',
'units': 'tree[string]',
'method': {
'_type': 'string',
'_default': 'deterministic'
Expand All @@ -138,25 +139,21 @@ def __init__(self, config=None, core=None):
self.copasi_model_object = fetch_biomodel(model_id=source_model_id)
# C. enter with a new model
else:
self.copasi_model_object = new_model(name='CopasiProcess Model')
self.copasi_model_object = new_model(name='CopasiProcess Model', **self.config.get('units'))

self.model_changes: Dict = self.config['model'].get('model_changes', {})

# add reactions
reaction_changes: Dict = self.model_changes.get('reaction_changes')
if reaction_changes:
for reaction_name, reaction_spec in reaction_changes.items():
add_reaction(
name=reaction_name,
scheme=reaction_spec,
model=self.copasi_model_object
)
reaction_changes: Dict = self.model_changes.get('reaction_changes', None)
if reaction_changes is not None:
for reaction_name, reaction_scheme in reaction_changes.items():
add_reaction(reaction_name, reaction_scheme, model=self.copasi_model_object)

# Get the species (floating only) TODO: add boundary species
self.floating_species_list = get_species(model=self.copasi_model_object).index.tolist()
self.floating_species_initial = get_species(model=self.copasi_model_object)['concentration'].tolist()

# Get the list of parameters and their values
# Get the list of parameters and their values (it is possible to run a model without any parameters)
self.model_parameters_list = get_parameters(model=self.copasi_model_object).index.tolist()
self.model_parameter_values = get_parameters(model=self.copasi_model_object)['initial_value'].tolist()

Expand Down
34 changes: 6 additions & 28 deletions notebooks/copasi_process_composer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -174,23 +174,9 @@
"source": [
"workflow = Composite({\n",
" 'state': instance\n",
"})\n",
"\n",
"# basico.set_report_dict('composite_process_model', task=T.TIME_COURSE)\n"
"})"
]
},
{
"cell_type": "code",
"outputs": [],
"source": [
"basico.T.TIME_COURSE"
],
"metadata": {
"collapsed": false
},
"id": "5690cd2793a5a53b",
"execution_count": null
},
{
"cell_type": "markdown",
"id": "6a402e48fbc30a5b",
Expand All @@ -213,18 +199,6 @@
"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 Expand Up @@ -291,7 +265,11 @@
" 'address': 'local:copasi',\n",
" 'config': {\n",
" 'model': {\n",
" 'model_changes':\n",
" 'model_changes': {\n",
" 'reaction_changes': {\n",
" 'R1': 'A -> B'\n",
" }\n",
" }\n",
" }\n",
" },\n",
" 'inputs': {\n",
Expand Down

0 comments on commit 27f17e7

Please sign in to comment.