From 84d713b8db53abf4b96f77ddade130a1282e1fef Mon Sep 17 00:00:00 2001 From: alexPatrie Date: Mon, 4 Mar 2024 13:24:16 -0500 Subject: [PATCH] updated notebook fix --- biosimulator_processes/utils.py | 1 + notebooks/copasi_process_composer.ipynb | 369 +++++++++++++++++++----- 2 files changed, 294 insertions(+), 76 deletions(-) diff --git a/biosimulator_processes/utils.py b/biosimulator_processes/utils.py index 51f2abcff..68c586596 100644 --- a/biosimulator_processes/utils.py +++ b/biosimulator_processes/utils.py @@ -239,6 +239,7 @@ def fix_execution_count(notebook_path): if cell['cell_type'] == 'code': if 'execution_count' not in cell: cell['execution_count'] = None + print('execution_count' in cell) with open(notebook_path, 'w', encoding='utf-8') as f: nbformat.write(nb, f) diff --git a/notebooks/copasi_process_composer.ipynb b/notebooks/copasi_process_composer.ipynb index 8dd0495bb..e89a37f1c 100644 --- a/notebooks/copasi_process_composer.ipynb +++ b/notebooks/copasi_process_composer.ipynb @@ -15,11 +15,11 @@ "execution_count": 1, "id": "b43cd4493a594e60", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:40.552145Z", "start_time": "2024-03-04T18:16:40.547337Z" - } + }, + "collapsed": false }, "outputs": [], "source": [ @@ -30,6 +30,15 @@ }, { "cell_type": "code", + "execution_count": 2, + "id": "65385e04f4f5dd1a", + "metadata": { + "ExecuteTime": { + "end_time": "2024-03-04T18:16:44.740326Z", + "start_time": "2024-03-04T18:16:40.740803Z" + }, + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -47,16 +56,7 @@ "from process_bigraph import pp, pf \n", "from biosimulator_processes.data_model import *\n", "from biosimulator_processes.biosimulator_builder import BiosimulatorBuilder" - ], - "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2024-03-04T18:16:44.740326Z", - "start_time": "2024-03-04T18:16:40.740803Z" - } - }, - "id": "65385e04f4f5dd1a", - "execution_count": 2 + ] }, { "cell_type": "markdown", @@ -73,11 +73,11 @@ "execution_count": 3, "id": "cc709690e20090cf", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:44.743127Z", "start_time": "2024-03-04T18:16:44.741263Z" - } + }, + "collapsed": false }, "outputs": [], "source": [ @@ -109,16 +109,18 @@ "execution_count": 4, "id": "edf123175ec3408c", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:45.946766Z", "start_time": "2024-03-04T18:16:45.942700Z" - } + }, + "collapsed": false }, "outputs": [ { "data": { - "text/plain": "True" + "text/plain": [ + "True" + ] }, "execution_count": 4, "metadata": {}, @@ -136,11 +138,11 @@ "execution_count": 5, "id": "40ab6f70ac3f4996", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:46.356620Z", "start_time": "2024-03-04T18:16:46.354301Z" - } + }, + "collapsed": false }, "outputs": [], "source": [ @@ -154,11 +156,11 @@ "execution_count": 6, "id": "d02a547b85138f96", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:46.739805Z", "start_time": "2024-03-04T18:16:46.737224Z" - } + }, + "collapsed": false }, "outputs": [ { @@ -191,11 +193,11 @@ "execution_count": 7, "id": "1b6c269646357d7d", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:47.333078Z", "start_time": "2024-03-04T18:16:47.329862Z" - } + }, + "collapsed": false }, "outputs": [ { @@ -237,11 +239,11 @@ "execution_count": 8, "id": "5d434956e65b1a42", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:47.811Z", "start_time": "2024-03-04T18:16:47.807927Z" - } + }, + "collapsed": false }, "outputs": [ { @@ -283,16 +285,30 @@ "execution_count": 9, "id": "de88e95d8f616779", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:48.288307Z", "start_time": "2024-03-04T18:16:48.285654Z" - } + }, + "collapsed": false }, "outputs": [ { "data": { - "text/plain": "{'model_id': 'copasi_process_from_file',\n 'model_source': {'value': '../biosimulator_processes/model_files/BIOMD0000000061_url.xml'},\n 'model_language': 'sbml',\n 'model_name': 'Simple Composite Process from File',\n 'model_changes': {'species_changes': [{'name': 'ADP',\n 'unit': '',\n 'initial_concentration': 9.261000000000001,\n 'initial_particle_number': None,\n 'initial_expression': '',\n 'expression': ''}],\n 'global_parameter_changes': [],\n 'reaction_changes': []},\n 'model_units': None}" + "text/plain": [ + "{'model_id': 'copasi_process_from_file',\n", + " 'model_source': {'value': '../biosimulator_processes/model_files/BIOMD0000000061_url.xml'},\n", + " 'model_language': 'sbml',\n", + " 'model_name': 'Simple Composite Process from File',\n", + " 'model_changes': {'species_changes': [{'name': 'ADP',\n", + " 'unit': '',\n", + " 'initial_concentration': 9.261000000000001,\n", + " 'initial_particle_number': None,\n", + " 'initial_expression': '',\n", + " 'expression': ''}],\n", + " 'global_parameter_changes': [],\n", + " 'reaction_changes': []},\n", + " 'model_units': None}" + ] }, "execution_count": 9, "metadata": {}, @@ -308,11 +324,11 @@ "execution_count": 10, "id": "52d81ea2ea688d47", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:48.904487Z", "start_time": "2024-03-04T18:16:48.722041Z" - } + }, + "collapsed": false }, "outputs": [], "source": [ @@ -328,24 +344,24 @@ }, { "cell_type": "markdown", - "source": [ - "Let's now add a biomodel with adjusted params (we know ahead of time)" - ], + "id": "80fd1a5aca61b442", "metadata": { "collapsed": false }, - "id": "80fd1a5aca61b442" + "source": [ + "Let's now add a biomodel with adjusted params (we know ahead of time)" + ] }, { "cell_type": "code", "execution_count": 11, "id": "f499f96a817d9faf", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:50.115960Z", "start_time": "2024-03-04T18:16:50.114064Z" - } + }, + "collapsed": false }, "outputs": [], "source": [ @@ -364,11 +380,11 @@ "execution_count": 12, "id": "c24594c6e8229e20", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:50.523673Z", "start_time": "2024-03-04T18:16:50.520712Z" - } + }, + "collapsed": false }, "outputs": [], "source": [ @@ -382,11 +398,11 @@ "execution_count": 13, "id": "454db50d61220bc5", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:50.988474Z", "start_time": "2024-03-04T18:16:50.986417Z" - } + }, + "collapsed": false }, "outputs": [], "source": [ @@ -416,11 +432,11 @@ "execution_count": 14, "id": "bd6781fe4a749c29", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:51.753456Z", "start_time": "2024-03-04T18:16:51.751025Z" - } + }, + "collapsed": false }, "outputs": [], "source": [ @@ -434,11 +450,11 @@ "execution_count": 15, "id": "e414174a2d6d331b", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:52.897856Z", "start_time": "2024-03-04T18:16:52.894173Z" - } + }, + "collapsed": false }, "outputs": [ { @@ -468,11 +484,11 @@ "execution_count": 16, "id": "9de88bc52fb9a164", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:53.574506Z", "start_time": "2024-03-04T18:16:53.571474Z" - } + }, + "collapsed": false }, "outputs": [ { @@ -517,11 +533,11 @@ "execution_count": 17, "id": "25ba11c1e1e75f94", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:54.320763Z", "start_time": "2024-03-04T18:16:54.318201Z" - } + }, + "collapsed": false }, "outputs": [ { @@ -579,11 +595,11 @@ "execution_count": 18, "id": "4c3f073b10e2dcc0", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:16:59.244410Z", "start_time": "2024-03-04T18:16:56.934443Z" - } + }, + "collapsed": false }, "outputs": [], "source": [ @@ -596,30 +612,172 @@ }, { "cell_type": "markdown", - "source": [ - "Visualize the added processes" - ], + "id": "974b09970316d79b", "metadata": { "collapsed": false }, - "id": "974b09970316d79b" + "source": [ + "Visualize the added processes" + ] }, { "cell_type": "code", "execution_count": 19, "id": "c5e03e6714faf9f4", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-03-04T18:17:00.597043Z", "start_time": "2024-03-04T18:17:00.378837Z" - } + }, + "collapsed": false }, "outputs": [ { "data": { - "image/svg+xml": "\n\n\n\n\n\nbigraph\n\n\n\n('simple_copasi_from_file', 'interval')\n\ninterval\n\n\n\n('copasi_process_from_biomodel', 'interval')\n\ninterval\n\n\n\n('simple_copasi_from_file',)\n\nsimple_copasi_from_file\n\n\n\n('simple_copasi_from_file',)->('simple_copasi_from_file', 'interval')\n\n\n\n\n('copasi_process_from_biomodel',)\n\ncopasi_process_from_biomodel\n\n\n\n('copasi_process_from_biomodel',)->('copasi_process_from_biomodel', 'interval')\n\n\n\n\n\n('simple_copasi_from_file', 't', 'i', 'm', 'e')->('simple_copasi_from_file',)\n\n\ntime\n\n\n\n('simple_copasi_from_file', 't', 'i', 'm', 'e')->('simple_copasi_from_file',)\n\n\ntime\n\n\n\n\n('simple_copasi_from_file', 'f', 'l', 'o', 'a', 't', 'i', 'n', 'g', '_', 's', 'p', 'e', 'c', 'i', 'e', 's')->('simple_copasi_from_file',)\n\n\nfloating_species\n\n\n\n('simple_copasi_from_file', 'f', 'l', 'o', 'a', 't', 'i', 'n', 'g', '_', 's', 'p', 'e', 'c', 'i', 'e', 's')->('simple_copasi_from_file',)\n\n\nfloating_species\n\n\n\n\n('simple_copasi_from_file', 'm', 'o', 'd', 'e', 'l', '_', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', 's')->('simple_copasi_from_file',)\n\n\nmodel_parameters\n\n\n\n\n('simple_copasi_from_file', 'r', 'e', 'a', 'c', 't', 'i', 'o', 'n', 's')->('simple_copasi_from_file',)\n\n\nreactions\n\n\n\n\n('copasi_process_from_biomodel', 't', 'i', 'm', 'e')->('copasi_process_from_biomodel',)\n\n\ntime\n\n\n\n('copasi_process_from_biomodel', 't', 'i', 'm', 'e')->('copasi_process_from_biomodel',)\n\n\ntime\n\n\n\n\n('copasi_process_from_biomodel', 'f', 'l', 'o', 'a', 't', 'i', 'n', 'g', '_', 's', 'p', 'e', 'c', 'i', 'e', 's')->('copasi_process_from_biomodel',)\n\n\nfloating_species\n\n\n\n('copasi_process_from_biomodel', 'f', 'l', 'o', 'a', 't', 'i', 'n', 'g', '_', 's', 'p', 'e', 'c', 'i', 'e', 's')->('copasi_process_from_biomodel',)\n\n\nfloating_species\n\n\n\n\n('copasi_process_from_biomodel', 'm', 'o', 'd', 'e', 'l', '_', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', 's')->('copasi_process_from_biomodel',)\n\n\nmodel_parameters\n\n\n\n\n('copasi_process_from_biomodel', 'r', 'e', 'a', 'c', 't', 'i', 'o', 'n', 's')->('copasi_process_from_biomodel',)\n\n\nreactions\n\n\n\n", - "text/plain": "" + "image/svg+xml": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "bigraph\n", + "\n", + "\n", + "\n", + "('simple_copasi_from_file', 'interval')\n", + "\n", + "interval\n", + "\n", + "\n", + "\n", + "('copasi_process_from_biomodel', 'interval')\n", + "\n", + "interval\n", + "\n", + "\n", + "\n", + "('simple_copasi_from_file',)\n", + "\n", + "simple_copasi_from_file\n", + "\n", + "\n", + "\n", + "('simple_copasi_from_file',)->('simple_copasi_from_file', 'interval')\n", + "\n", + "\n", + "\n", + "\n", + "('copasi_process_from_biomodel',)\n", + "\n", + "copasi_process_from_biomodel\n", + "\n", + "\n", + "\n", + "('copasi_process_from_biomodel',)->('copasi_process_from_biomodel', 'interval')\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "('simple_copasi_from_file', 't', 'i', 'm', 'e')->('simple_copasi_from_file',)\n", + "\n", + "\n", + "time\n", + "\n", + "\n", + "\n", + "('simple_copasi_from_file', 't', 'i', 'm', 'e')->('simple_copasi_from_file',)\n", + "\n", + "\n", + "time\n", + "\n", + "\n", + "\n", + "\n", + "('simple_copasi_from_file', 'f', 'l', 'o', 'a', 't', 'i', 'n', 'g', '_', 's', 'p', 'e', 'c', 'i', 'e', 's')->('simple_copasi_from_file',)\n", + "\n", + "\n", + "floating_species\n", + "\n", + "\n", + "\n", + "('simple_copasi_from_file', 'f', 'l', 'o', 'a', 't', 'i', 'n', 'g', '_', 's', 'p', 'e', 'c', 'i', 'e', 's')->('simple_copasi_from_file',)\n", + "\n", + "\n", + "floating_species\n", + "\n", + "\n", + "\n", + "\n", + "('simple_copasi_from_file', 'm', 'o', 'd', 'e', 'l', '_', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', 's')->('simple_copasi_from_file',)\n", + "\n", + "\n", + "model_parameters\n", + "\n", + "\n", + "\n", + "\n", + "('simple_copasi_from_file', 'r', 'e', 'a', 'c', 't', 'i', 'o', 'n', 's')->('simple_copasi_from_file',)\n", + "\n", + "\n", + "reactions\n", + "\n", + "\n", + "\n", + "\n", + "('copasi_process_from_biomodel', 't', 'i', 'm', 'e')->('copasi_process_from_biomodel',)\n", + "\n", + "\n", + "time\n", + "\n", + "\n", + "\n", + "('copasi_process_from_biomodel', 't', 'i', 'm', 'e')->('copasi_process_from_biomodel',)\n", + "\n", + "\n", + "time\n", + "\n", + "\n", + "\n", + "\n", + "('copasi_process_from_biomodel', 'f', 'l', 'o', 'a', 't', 'i', 'n', 'g', '_', 's', 'p', 'e', 'c', 'i', 'e', 's')->('copasi_process_from_biomodel',)\n", + "\n", + "\n", + "floating_species\n", + "\n", + "\n", + "\n", + "('copasi_process_from_biomodel', 'f', 'l', 'o', 'a', 't', 'i', 'n', 'g', '_', 's', 'p', 'e', 'c', 'i', 'e', 's')->('copasi_process_from_biomodel',)\n", + "\n", + "\n", + "floating_species\n", + "\n", + "\n", + "\n", + "\n", + "('copasi_process_from_biomodel', 'm', 'o', 'd', 'e', 'l', '_', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', 's')->('copasi_process_from_biomodel',)\n", + "\n", + "\n", + "model_parameters\n", + "\n", + "\n", + "\n", + "\n", + "('copasi_process_from_biomodel', 'r', 'e', 'a', 'c', 't', 'i', 'o', 'n', 's')->('copasi_process_from_biomodel',)\n", + "\n", + "\n", + "reactions\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] }, "execution_count": 19, "metadata": {}, @@ -632,20 +790,87 @@ }, { "cell_type": "markdown", - "source": [ - "Connect the processes together with the default store name:" - ], + "id": "1438b52fbe49c4eb", "metadata": { "collapsed": false }, - "id": "1438b52fbe49c4eb" + "source": [ + "Connect the processes together with the default store name:" + ] }, { "cell_type": "code", + "execution_count": 20, + "id": "d9bef3f51b50fbd5", + "metadata": { + "ExecuteTime": { + "end_time": "2024-03-04T18:17:08.884244Z", + "start_time": "2024-03-04T18:17:08.876800Z" + }, + "collapsed": false + }, "outputs": [ { "data": { - "text/plain": "Builder({ 'copasi_process_from_biomodel': { '_type': 'process',\n 'address': 'local:CopasiProcess',\n 'config': { 'method': 'directMethod',\n 'model': { 'model_changes': { 'global_parameter_changes': [ ],\n 'reaction_changes': [ { 'parameter_changes': [ { 'parameter_name': 'EpoRpRJAK2',\n 'value': 21312.2},\n { 'parameter_name': 'EpoRJAK2',\n 'value': 21312.2}],\n 'reaction_name': 'reaction_1',\n 'reaction_scheme': None},\n { 'parameter_changes': [ ],\n 'reaction_name': 'reaction_11',\n 'reaction_scheme': 'A '\n '+ '\n 'B '\n '-> '\n 'C'}],\n 'species_changes': [ ]},\n 'model_id': 'BIOMD0000000861',\n 'model_language': 'sbml',\n 'model_name': 'composite_from_biomodel',\n 'model_source': { 'value': 'BIOMD0000000861'},\n 'model_units': None}},\n 'inputs': { 'floating_species': [ 'floating_species_store'],\n 'model_parameters': [ 'model_parameters_store'],\n 'reactions': [ 'reactions_store'],\n 'time': ['time_store']},\n 'instance': ,\n 'interval': 1.0,\n 'outputs': { 'floating_species': [ 'floating_species_store'],\n 'time': ['time_store']}},\n 'simple_copasi_from_file': { '_type': 'process',\n 'address': 'local:CopasiProcess',\n 'config': { 'method': 'stochastic',\n 'model': { 'model_changes': { 'global_parameter_changes': [ ],\n 'reaction_changes': [ ],\n 'species_changes': [ { 'expression': '',\n 'initial_concentration': 9.261000000000001,\n 'initial_expression': '',\n 'initial_particle_number': None,\n 'unit': ''}]},\n 'model_id': 'copasi_process_from_file',\n 'model_language': 'sbml',\n 'model_name': 'Simple '\n 'Composite '\n 'Process '\n 'from File',\n 'model_source': { 'value': '../biosimulator_processes/model_files/BIOMD0000000061_url.xml'},\n 'model_units': None}},\n 'inputs': { 'floating_species': [ 'floating_species_store'],\n 'model_parameters': [ 'model_parameters_store'],\n 'reactions': ['reactions_store'],\n 'time': ['time_store']},\n 'instance': ,\n 'interval': 1.0,\n 'outputs': { 'floating_species': [ 'floating_species_store'],\n 'time': ['time_store']}}})" + "text/plain": [ + "Builder({ 'copasi_process_from_biomodel': { '_type': 'process',\n", + " 'address': 'local:CopasiProcess',\n", + " 'config': { 'method': 'directMethod',\n", + " 'model': { 'model_changes': { 'global_parameter_changes': [ ],\n", + " 'reaction_changes': [ { 'parameter_changes': [ { 'parameter_name': 'EpoRpRJAK2',\n", + " 'value': 21312.2},\n", + " { 'parameter_name': 'EpoRJAK2',\n", + " 'value': 21312.2}],\n", + " 'reaction_name': 'reaction_1',\n", + " 'reaction_scheme': None},\n", + " { 'parameter_changes': [ ],\n", + " 'reaction_name': 'reaction_11',\n", + " 'reaction_scheme': 'A '\n", + " '+ '\n", + " 'B '\n", + " '-> '\n", + " 'C'}],\n", + " 'species_changes': [ ]},\n", + " 'model_id': 'BIOMD0000000861',\n", + " 'model_language': 'sbml',\n", + " 'model_name': 'composite_from_biomodel',\n", + " 'model_source': { 'value': 'BIOMD0000000861'},\n", + " 'model_units': None}},\n", + " 'inputs': { 'floating_species': [ 'floating_species_store'],\n", + " 'model_parameters': [ 'model_parameters_store'],\n", + " 'reactions': [ 'reactions_store'],\n", + " 'time': ['time_store']},\n", + " 'instance': ,\n", + " 'interval': 1.0,\n", + " 'outputs': { 'floating_species': [ 'floating_species_store'],\n", + " 'time': ['time_store']}},\n", + " 'simple_copasi_from_file': { '_type': 'process',\n", + " 'address': 'local:CopasiProcess',\n", + " 'config': { 'method': 'stochastic',\n", + " 'model': { 'model_changes': { 'global_parameter_changes': [ ],\n", + " 'reaction_changes': [ ],\n", + " 'species_changes': [ { 'expression': '',\n", + " 'initial_concentration': 9.261000000000001,\n", + " 'initial_expression': '',\n", + " 'initial_particle_number': None,\n", + " 'unit': ''}]},\n", + " 'model_id': 'copasi_process_from_file',\n", + " 'model_language': 'sbml',\n", + " 'model_name': 'Simple '\n", + " 'Composite '\n", + " 'Process '\n", + " 'from File',\n", + " 'model_source': { 'value': '../biosimulator_processes/model_files/BIOMD0000000061_url.xml'},\n", + " 'model_units': None}},\n", + " 'inputs': { 'floating_species': [ 'floating_species_store'],\n", + " 'model_parameters': [ 'model_parameters_store'],\n", + " 'reactions': ['reactions_store'],\n", + " 'time': ['time_store']},\n", + " 'instance': ,\n", + " 'interval': 1.0,\n", + " 'outputs': { 'floating_species': [ 'floating_species_store'],\n", + " 'time': ['time_store']}}})" + ] }, "execution_count": 20, "metadata": {}, @@ -656,25 +881,17 @@ "b.connect_all(append_to_store_name='_store')\n", "\n", "b" - ], - "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2024-03-04T18:17:08.884244Z", - "start_time": "2024-03-04T18:17:08.876800Z" - } - }, - "id": "d9bef3f51b50fbd5", - "execution_count": 20 + ] }, { "cell_type": "code", - "outputs": [], - "source": [], + "execution_count": null, + "id": "30ace33f0337beb4", "metadata": { "collapsed": false }, - "id": "30ace33f0337beb4" + "outputs": [], + "source": [] } ], "metadata": {