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

Commit

Permalink
updated composer
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Mar 1, 2024
1 parent 4587d8c commit 93944fd
Showing 1 changed file with 117 additions and 22 deletions.
139 changes: 117 additions & 22 deletions notebooks/builder_composer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"id": "b385dca6-942d-472c-9963-13b8cb33843c",
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-01T18:50:04.271919Z",
"start_time": "2024-03-01T18:50:04.260886Z"
}
},
"outputs": [],
"source": [
"from builder import Builder, Process\n",
"from process_bigraph import pp, pf \n",
"from biosimulator_processes import CORE\n",
"from biosimulator_processes.data_model import *\n",
"from biosimulator_processes.biosimulator_builder import BiosimulatorBuilder"
Expand Down Expand Up @@ -128,55 +134,144 @@
"cell_type": "code",
"outputs": [
{
"data": {
"text/plain": "{'species_changes': {'species_name': 'SHP1',\n 'unit': None,\n 'initial_concentration': 5.0,\n 'initial_particle_number': None,\n 'initial_expression': None,\n 'expression': None},\n 'global_parameter_changes': None,\n 'reaction_changes': None}"
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
"name": "stdout",
"output_type": "stream",
"text": [
"{ 'global_parameter_changes': None,\n",
" 'reaction_changes': None,\n",
" 'species_changes': { 'expression': None,\n",
" 'initial_concentration': 5.0,\n",
" 'initial_expression': None,\n",
" 'initial_particle_number': None,\n",
" 'species_name': 'SHP1',\n",
" 'unit': None}}\n"
]
}
],
"source": [
"# 1. specify model changes\n",
"\n",
"process_model_changes = ModelChanges(\n",
" species_changes=SpeciesChanges(\n",
" species_name='SHP1',\n",
" initial_concentration=5.00000\n",
" )\n",
")\n",
"\n",
"process_model_changes.model_dump()"
"\n",
"pp(process_model_changes.model_dump())"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-01T18:46:50.284003Z",
"start_time": "2024-03-01T18:46:50.279111Z"
"end_time": "2024-03-01T18:51:15.399056Z",
"start_time": "2024-03-01T18:51:15.392102Z"
}
},
"id": "2b1c1bdd6864a771",
"execution_count": 13
"execution_count": 23
},
{
"cell_type": "code",
"execution_count": null,
"id": "b79dc6639a17e353",
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{ 'model_changes': { 'global_parameter_changes': None,\n",
" 'reaction_changes': None,\n",
" 'species_changes': { 'expression': None,\n",
" 'initial_concentration': 5.0,\n",
" 'initial_expression': None,\n",
" 'initial_particle_number': None,\n",
" 'species_name': 'SHP1',\n",
" 'unit': None}},\n",
" 'model_id': 'simple_copasi_process',\n",
" 'model_language': 'sbml',\n",
" 'model_name': 'Simple Composite Process',\n",
" 'model_source': {'value': 'BIOMD0000000861'}}\n"
]
}
],
"source": [
"# 2. define the model schema to be used by the composite process (one of the copasiprocess config parameters)\n",
"\n",
"process_model = Model(\n",
" model_id='simple_copasi_process',\n",
" model_source='BIOMD0000000861',\n",
" model_name='Simple Composite Process',\n",
" model_changes=\n",
" model_changes=process_model_changes\n",
")\n",
"\n",
"\n",
"pp(process_model.model_dump())"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-01T18:52:11.944029Z",
"start_time": "2024-03-01T18:52:11.940871Z"
}
},
"id": "8d0566183a2d1c1f",
"execution_count": 25
},
{
"cell_type": "code",
"execution_count": 27,
"id": "b79dc6639a17e353",
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-03-01T18:53:12.797999Z",
"start_time": "2024-03-01T18:53:12.791670Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{ 'method': 'stochastic',\n",
" 'model': { 'model_changes': { 'global_parameter_changes': None,\n",
" 'reaction_changes': None,\n",
" 'species_changes': { 'expression': None,\n",
" 'initial_concentration': 5.0,\n",
" 'initial_expression': None,\n",
" 'initial_particle_number': None,\n",
" 'species_name': 'SHP1',\n",
" 'unit': None}},\n",
" 'model_id': 'simple_copasi_process',\n",
" 'model_language': 'sbml',\n",
" 'model_name': 'Simple Composite Process',\n",
" 'model_source': {'value': 'BIOMD0000000861'}}}\n"
]
}
],
"source": [
"# 3. Define config schema to be used as 'config' parameter of Process constructor\n",
"\n",
"\n",
"process_config = CopasiProcessConfigSchema(\n",
" \n",
")"
" method='stochastic',\n",
" model=process_model\n",
")\n",
"\n",
"\n",
"pp(process_config.model_dump())"
]
},
{
"cell_type": "code",
"outputs": [],
"source": [
"dir()"
],
"metadata": {
"collapsed": false
},
"id": "a8bc9415d6ac47ad"
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -185,7 +280,7 @@
"outputs": [],
"source": [
"\n",
"b['copasi_A'].add_process(\n",
"b['simple_copasi'].add_process(\n",
" name='CopasiProcess',\n",
" kdeg=1.0, # kwargs fill parameters in the config\n",
")"
Expand Down

0 comments on commit 93944fd

Please sign in to comment.