diff --git a/notebooks/copasi_process_composer.ipynb b/notebooks/copasi_process_composer.ipynb index 307830958..8dd0495bb 100644 --- a/notebooks/copasi_process_composer.ipynb +++ b/notebooks/copasi_process_composer.ipynb @@ -17,8 +17,8 @@ "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2024-03-04T18:12:46.780098Z", - "start_time": "2024-03-04T18:12:46.776381Z" + "end_time": "2024-03-04T18:16:40.552145Z", + "start_time": "2024-03-04T18:16:40.547337Z" } }, "outputs": [], @@ -51,8 +51,8 @@ "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2024-03-04T18:13:02.776479Z", - "start_time": "2024-03-04T18:12:47.630719Z" + "end_time": "2024-03-04T18:16:44.740326Z", + "start_time": "2024-03-04T18:16:40.740803Z" } }, "id": "65385e04f4f5dd1a", @@ -70,10 +70,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "cc709690e20090cf", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:44.743127Z", + "start_time": "2024-03-04T18:16:44.741263Z" + } }, "outputs": [], "source": [ @@ -102,12 +106,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "edf123175ec3408c", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:45.946766Z", + "start_time": "2024-03-04T18:16:45.942700Z" + } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": "True" + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "model_filepath = '../biosimulator_processes/model_files/BIOMD0000000061_url.xml'\n", "\n", @@ -116,10 +133,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "40ab6f70ac3f4996", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:46.356620Z", + "start_time": "2024-03-04T18:16:46.354301Z" + } }, "outputs": [], "source": [ @@ -130,12 +151,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "d02a547b85138f96", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:46.739805Z", + "start_time": "2024-03-04T18:16:46.737224Z" + } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{ 'global_parameter_changes': [],\n", + " 'reaction_changes': [],\n", + " 'species_changes': [ { 'expression': '',\n", + " 'initial_concentration': 9.261000000000001,\n", + " 'initial_expression': '',\n", + " 'initial_particle_number': None,\n", + " 'name': 'ADP',\n", + " 'unit': ''}]}\n" + ] + } + ], "source": [ "# 1. specify model changes (we know the model specs as we are providing the file. TODO: allow users to introspect the model before change)\n", "process_model_changes = ModelChanges(\n", @@ -148,12 +188,36 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "1b6c269646357d7d", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:47.333078Z", + "start_time": "2024-03-04T18:16:47.329862Z" + } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{ '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", + " 'name': 'ADP',\n", + " 'unit': ''}]},\n", + " 'model_id': 'copasi_process_from_file',\n", + " 'model_language': 'sbml',\n", + " 'model_name': 'Simple Composite Process from File',\n", + " 'model_source': { 'value': '../biosimulator_processes/model_files/BIOMD0000000061_url.xml'},\n", + " 'model_units': None}\n" + ] + } + ], "source": [ "# 2. define the model schema to be used by the composite process (one of the copasiprocess config parameters)\n", "\n", @@ -170,12 +234,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "5d434956e65b1a42", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:47.811Z", + "start_time": "2024-03-04T18:16:47.807927Z" + } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{ '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", + " 'name': 'ADP',\n", + " 'unit': ''}]},\n", + " 'model_id': 'copasi_process_from_file',\n", + " 'model_language': 'sbml',\n", + " 'model_name': 'Simple Composite Process from File',\n", + " 'model_source': { 'value': '../biosimulator_processes/model_files/BIOMD0000000061_url.xml'},\n", + " 'model_units': None},\n", + " 'process_name': 'simple_copasi_from_file'}\n" + ] + } + ], "source": [ "# 3. Define config schema to be used as 'config' parameter of Process constructor\n", "process_config_from_file = CopasiProcessConfigSchema(\n", @@ -190,22 +280,39 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "de88e95d8f616779", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:48.288307Z", + "start_time": "2024-03-04T18:16:48.285654Z" + } }, - "outputs": [], + "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}" + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "process_config_from_file.model" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "52d81ea2ea688d47", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:48.904487Z", + "start_time": "2024-03-04T18:16:48.722041Z" + } }, "outputs": [], "source": [ @@ -231,10 +338,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "f499f96a817d9faf", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:50.115960Z", + "start_time": "2024-03-04T18:16:50.114064Z" + } }, "outputs": [], "source": [ @@ -250,10 +361,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "id": "c24594c6e8229e20", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:50.523673Z", + "start_time": "2024-03-04T18:16:50.520712Z" + } }, "outputs": [], "source": [ @@ -264,10 +379,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "id": "454db50d61220bc5", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:50.988474Z", + "start_time": "2024-03-04T18:16:50.986417Z" + } }, "outputs": [], "source": [ @@ -294,10 +413,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "id": "bd6781fe4a749c29", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:51.753456Z", + "start_time": "2024-03-04T18:16:51.751025Z" + } }, "outputs": [], "source": [ @@ -308,24 +431,73 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "e414174a2d6d331b", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:52.897856Z", + "start_time": "2024-03-04T18:16:52.894173Z" + } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{ '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 + B -> C'}],\n", + " 'species_changes': []}\n" + ] + } + ], "source": [ "pp(biomodel_process_changes.model_dump())" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "9de88bc52fb9a164", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:53.574506Z", + "start_time": "2024-03-04T18:16:53.571474Z" + } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{ '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 + B -> 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" + ] + } + ], "source": [ "biomodel_id = 'BIOMD0000000861'\n", "\n", @@ -342,12 +514,45 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "id": "25ba11c1e1e75f94", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:54.320763Z", + "start_time": "2024-03-04T18:16:54.318201Z" + } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{ '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", + " 'process_name': 'copasi_process_from_biomodel'}\n" + ] + } + ], "source": [ "biomodel_process_config = CopasiProcessConfigSchema(\n", " process_name='copasi_process_from_biomodel',\n", @@ -371,10 +576,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "4c3f073b10e2dcc0", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:16:59.244410Z", + "start_time": "2024-03-04T18:16:56.934443Z" + } }, "outputs": [], "source": [ @@ -397,12 +606,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "c5e03e6714faf9f4", "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:17:00.597043Z", + "start_time": "2024-03-04T18:17:00.378837Z" + } }, - "outputs": [], + "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": "" + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "b.visualize()" ] @@ -419,17 +642,30 @@ }, { "cell_type": "code", - "outputs": [], + "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']}}})" + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "b.connect_all(append_to_store_name='_store')\n", "\n", "b" ], "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-03-04T18:17:08.884244Z", + "start_time": "2024-03-04T18:17:08.876800Z" + } }, "id": "d9bef3f51b50fbd5", - "execution_count": null + "execution_count": 20 }, { "cell_type": "code",