{ "cells": [ { "cell_type": "markdown", "id": "3bbe8002-bdf3-490c-bde0-80dd3713a3d0", "metadata": {}, "source": [ "## `A <-> B` , downregulated by the \"shunt\" (coupled reaction) `A <-> S`\n", "### _Kinetic_ advantage (downregulation in early phase) vs. _Thermodynamic_ advantage (long-term downregulation) \n", "\n", "**[Scenario 1](#down_regulate_1_scenario_1)** : No downregulation on `A <-> B `\n", "\n", "**[Scenario 2](#down_regulate_1_scenario_2)** : The shunt (`A <-> S`) has a *kinetic* advantage but *thermodynamic* DIS-advantage compared to `A <-> B ` \n", "(i.e. `A <-> S` is fast, but energetically unfavored) \n", "\n", "**[Scenario 3](#down_regulate_1_scenario_3)** : The shunt (`A <-> S`) is has a *kinetic* DIS-advantage but a *thermodynamic* advantage compared to `A <-> B` \n", "(i.e. `A <-> S` is slow, but energetically favored) \n", "\n", "All reactions 1st order, mostly forward. Taken to equilibrium.\n", "\n", "LAST REVISED: Dec. 3, 2023" ] }, { "cell_type": "markdown", "id": "61171e99-518e-4019-a731-be7437e95dfd", "metadata": {}, "source": [ "## Bathtub analogy:\n", "A is initially full, while B and S are empty. \n", "If the \"shunt\" S is present, scenario 2 corresponds to a large pipe and a small elevation change... \n", "while scenario 3 corresponds to a narrow pipe and a large elevation change." ] }, { "cell_type": "markdown", "id": "832afe37-f169-41c8-a719-e739336bc5cf", "metadata": {}, "source": [ "" ] }, { "cell_type": "code", "execution_count": 1, "id": "c4231a63-e456-48e9-bf4f-d074bbd3490a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Added 'D:\\Docs\\- MY CODE\\BioSimulations\\life123-Win7' to sys.path\n" ] } ], "source": [ "import set_path # Importing this module will add the project's home directory to sys.path" ] }, { "cell_type": "code", "execution_count": 2, "id": "64933384", "metadata": { "tags": [] }, "outputs": [], "source": [ "from experiments.get_notebook_info import get_notebook_basename\n", "\n", "from src.modules.chemicals.chem_data import ChemData as chem\n", "from src.modules.reactions.reaction_dynamics import ReactionDynamics\n", "\n", "import plotly.express as px\n", "from src.modules.visualization.graphic_log import GraphicLog" ] }, { "cell_type": "code", "execution_count": 3, "id": "83c3cc5f-de21-4f66-9988-2806fbf0666d", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-> Output will be LOGGED into the file 'down_regulate_1.log.htm'\n" ] } ], "source": [ "# Initialize the HTML logging (for the graphics)\n", "log_file = get_notebook_basename() + \".log.htm\" # Use the notebook base filename for the log file\n", "\n", "# Set up the use of some specified graphic (Vue) components\n", "GraphicLog.config(filename=log_file,\n", " components=[\"vue_cytoscape_1\"],\n", " extra_js=\"https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.21.2/cytoscape.umd.js\")" ] }, { "cell_type": "code", "execution_count": null, "id": "001bc666-f2ef-40a3-b46f-30b087ea33da", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "35b5ef15-69da-4fc9-b1e9-fd34a9bafb99", "metadata": {}, "source": [ "# Scenario 1: A <-> B in the absence of the 2nd reaction" ] }, { "cell_type": "markdown", "id": "9329208b-070f-4902-8f37-0f11ddf75ed6", "metadata": {}, "source": [ "### Initialize the System\n", "Specify the chemicals and the reaction" ] }, { "cell_type": "code", "execution_count": 4, "id": "57d8431c-d6d0-462c-af78-e64eeb220e2e", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of reactions: 1 (at temp. 25 C)\n", "0: A <-> B (kF = 30 / kR = 5 / delta_G = -4,441.7 / K = 6) | 1st order in all reactants & products\n", "Set of chemicals involved in the above reactions: {'A', 'B'}\n" ] } ], "source": [ "# Specify the chemicals\n", "chem_data = chem(names=[\"A\", \"B\"])\n", "\n", "# Reaction A <-> B\n", "chem_data.add_reaction(reactants=[\"A\"], products=[\"B\"],\n", " forward_rate=30., reverse_rate=5.)\n", "\n", "chem_data.describe_reactions()" ] }, { "cell_type": "markdown", "id": "f5eabdf2-0e6b-4141-a886-10974dfc6c3a", "metadata": {}, "source": [ "### Set the initial concentrations of all the chemicals, in their index order" ] }, { "cell_type": "code", "execution_count": 5, "id": "67a0375f-a14f-4cbe-965b-81d4c841aeab", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SYSTEM STATE at Time t = 0:\n", "2 species:\n", " Species 0 (A). Conc: 50.0\n", " Species 1 (B). Conc: 0.0\n", "Set of chemicals involved in reactions: {'A', 'B'}\n" ] } ], "source": [ "dynamics = ReactionDynamics(chem_data=chem_data)\n", "dynamics.set_conc([50., 0.], snapshot=True)\n", "dynamics.describe_state()" ] }, { "cell_type": "markdown", "id": "72a2148e-1aae-4ed7-bab3-5781b3a80fb0", "metadata": {}, "source": [ "### Run the reaction" ] }, { "cell_type": "code", "execution_count": 6, "id": "89f23b49-2840-4517-a275-b6a4f97898af", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "49 total step(s) taken\n" ] } ], "source": [ "dynamics.set_diagnostics() # To save diagnostic information about the call to single_compartment_react()\n", "\n", "# All of these settings are currently close to the default values... but subject to change; set for repeatability\n", "dynamics.set_thresholds(norm=\"norm_A\", low=0.5, high=1.0, abort=1.44)\n", "dynamics.set_thresholds(norm=\"norm_B\", low=0.08, high=0.5, abort=1.5)\n", "dynamics.set_step_factors(upshift=1.5, downshift=0.5, abort=0.5)\n", "dynamics.set_error_step_factor(0.5)\n", "\n", "# The changes of concentrations vary very rapidly early on; automated variable timesteps will take care of that\n", "dynamics.single_compartment_react(initial_step=0.001, reaction_duration=0.3,\n", " snapshots={\"initial_caption\": \"1st reaction step\",\n", " \"final_caption\": \"last reaction step\"},\n", " variable_steps=True, explain_variable_steps=False)" ] }, { "cell_type": "code", "execution_count": 7, "id": "80fbaee3-bd6f-4197-9270-23374d46a4a7", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | SYSTEM TIME | \n", "A | \n", "B | \n", "caption | \n", "
|---|---|---|---|---|
| 0 | \n", "0.000000 | \n", "50.000000 | \n", "0.000000 | \n", "Initial state | \n", "
| 1 | \n", "0.001000 | \n", "48.500000 | \n", "1.500000 | \n", "1st reaction step | \n", "
| 2 | \n", "0.001500 | \n", "47.776250 | \n", "2.223750 | \n", "\n", " |
| 3 | \n", "0.002000 | \n", "47.065166 | \n", "2.934834 | \n", "\n", " |
| 4 | \n", "0.002500 | \n", "46.366525 | \n", "3.633475 | \n", "\n", " |
| 5 | \n", "0.003000 | \n", "45.680111 | \n", "4.319889 | \n", "\n", " |
| 6 | \n", "0.003500 | \n", "45.005709 | \n", "4.994291 | \n", "\n", " |
| 7 | \n", "0.004000 | \n", "44.343109 | \n", "5.656891 | \n", "\n", " |
| 8 | \n", "0.004500 | \n", "43.692105 | \n", "6.307895 | \n", "\n", " |
| 9 | \n", "0.005000 | \n", "43.052493 | \n", "6.947507 | \n", "\n", " |
| 10 | \n", "0.005500 | \n", "42.424074 | \n", "7.575926 | \n", "\n", " |
| 11 | \n", "0.006000 | \n", "41.806653 | \n", "8.193347 | \n", "\n", " |
| 12 | \n", "0.006500 | \n", "41.200037 | \n", "8.799963 | \n", "\n", " |
| 13 | \n", "0.007250 | \n", "40.306036 | \n", "9.693964 | \n", "\n", " |
| 14 | \n", "0.008000 | \n", "39.435502 | \n", "10.564498 | \n", "\n", " |
| 15 | \n", "0.008750 | \n", "38.587820 | \n", "11.412180 | \n", "\n", " |
| 16 | \n", "0.009500 | \n", "37.762390 | \n", "12.237610 | \n", "\n", " |
| 17 | \n", "0.010625 | \n", "36.556746 | \n", "13.443254 | \n", "\n", " |
| 18 | \n", "0.011750 | \n", "35.398574 | \n", "14.601426 | \n", "\n", " |
| 19 | \n", "0.012875 | \n", "34.286005 | \n", "15.713995 | \n", "\n", " |
| 20 | \n", "0.014000 | \n", "33.217244 | \n", "16.782756 | \n", "\n", " |
| 21 | \n", "0.015125 | \n", "32.190565 | \n", "17.809435 | \n", "\n", " |
| 22 | \n", "0.016250 | \n", "31.204311 | \n", "18.795689 | \n", "\n", " |
| 23 | \n", "0.017938 | \n", "29.783182 | \n", "20.216818 | \n", "\n", " |
| 24 | \n", "0.018781 | \n", "29.114585 | \n", "20.885415 | \n", "\n", " |
| 25 | \n", "0.020047 | \n", "28.141306 | \n", "21.858694 | \n", "\n", " |
| 26 | \n", "0.021945 | \n", "26.746057 | \n", "23.253943 | \n", "\n", " |
| 27 | \n", "0.023844 | \n", "25.443516 | \n", "24.556484 | \n", "\n", " |
| 28 | \n", "0.025742 | \n", "24.227523 | \n", "25.772477 | \n", "\n", " |
| 29 | \n", "0.027641 | \n", "23.092327 | \n", "26.907673 | \n", "\n", " |
| 30 | \n", "0.029539 | \n", "22.032560 | \n", "27.967440 | \n", "\n", " |
| 31 | \n", "0.031438 | \n", "21.043209 | \n", "28.956791 | \n", "\n", " |
| 32 | \n", "0.034285 | \n", "19.657789 | \n", "30.342211 | \n", "\n", " |
| 33 | \n", "0.037133 | \n", "18.410451 | \n", "31.589549 | \n", "\n", " |
| 34 | \n", "0.039980 | \n", "17.287433 | \n", "32.712567 | \n", "\n", " |
| 35 | \n", "0.042828 | \n", "16.276344 | \n", "33.723656 | \n", "\n", " |
| 36 | \n", "0.045676 | \n", "15.366028 | \n", "34.633972 | \n", "\n", " |
| 37 | \n", "0.049947 | \n", "14.136648 | \n", "35.863352 | \n", "\n", " |
| 38 | \n", "0.054219 | \n", "13.091062 | \n", "36.908938 | \n", "\n", " |
| 39 | \n", "0.058490 | \n", "12.201794 | \n", "37.798206 | \n", "\n", " |
| 40 | \n", "0.064897 | \n", "11.067313 | \n", "38.932687 | \n", "\n", " |
| 41 | \n", "0.071305 | \n", "10.187242 | \n", "39.812758 | \n", "\n", " |
| 42 | \n", "0.080916 | \n", "9.163174 | \n", "40.836826 | \n", "\n", " |
| 43 | \n", "0.090526 | \n", "8.483581 | \n", "41.516419 | \n", "\n", " |
| 44 | \n", "0.104943 | \n", "7.807093 | \n", "42.192907 | \n", "\n", " |
| 45 | \n", "0.126567 | \n", "7.304364 | \n", "42.695636 | \n", "\n", " |
| 46 | \n", "0.159004 | \n", "7.121008 | \n", "42.878992 | \n", "\n", " |
| 47 | \n", "0.207658 | \n", "7.158215 | \n", "42.841785 | \n", "\n", " |
| 48 | \n", "0.280641 | \n", "7.118985 | \n", "42.881015 | \n", "\n", " |
| 49 | \n", "0.390114 | \n", "7.210452 | \n", "42.789548 | \n", "last reaction step | \n", "
| \n", " | SYSTEM TIME | \n", "A | \n", "B | \n", "S | \n", "caption | \n", "
|---|---|---|---|---|---|
| 0 | \n", "0.000000 | \n", "50.000000 | \n", "0.000000 | \n", "0.000000 | \n", "Initial state | \n", "
| 1 | \n", "0.000250 | \n", "47.750000 | \n", "0.375000 | \n", "1.875000 | \n", "1st reaction step | \n", "
| 2 | \n", "0.000500 | \n", "45.648594 | \n", "0.732656 | \n", "3.618750 | \n", "\n", " |
| 3 | \n", "0.000625 | \n", "44.667193 | \n", "0.903381 | \n", "4.429427 | \n", "\n", " |
| 4 | \n", "0.000750 | \n", "43.718113 | \n", "1.070318 | \n", "5.211569 | \n", "\n", " |
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 65 | \n", "0.162354 | \n", "6.593940 | \n", "33.315058 | \n", "10.091002 | \n", "\n", " |
| 66 | \n", "0.181800 | \n", "6.375490 | \n", "33.922608 | \n", "9.701902 | \n", "\n", " |
| 67 | \n", "0.209024 | \n", "6.163548 | \n", "34.512062 | \n", "9.324390 | \n", "\n", " |
| 68 | \n", "0.247138 | \n", "5.994349 | \n", "34.982624 | \n", "9.023027 | \n", "\n", " |
| 69 | \n", "0.300498 | \n", "5.900061 | \n", "35.245013 | \n", "8.854926 | \n", "last reaction step | \n", "
70 rows × 5 columns
\n", "| \n", " | SYSTEM TIME | \n", "A | \n", "B | \n", "S | \n", "caption | \n", "
|---|---|---|---|---|---|
| 0 | \n", "0.000000 | \n", "50.000000 | \n", "0.000000 | \n", "0.000000 | \n", "Initial state | \n", "
| 1 | \n", "0.001250 | \n", "47.937500 | \n", "1.875000 | \n", "0.187500 | \n", "1st reaction step | \n", "
| 2 | \n", "0.002500 | \n", "45.971820 | \n", "3.660938 | \n", "0.367242 | \n", "\n", " |
| 3 | \n", "0.002812 | \n", "45.503468 | \n", "4.086203 | \n", "0.410329 | \n", "\n", " |
| 4 | \n", "0.003125 | \n", "45.040611 | \n", "4.506413 | \n", "0.452976 | \n", "\n", " |
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 450 | \n", "6.518546 | \n", "1.538995 | \n", "9.356824 | \n", "39.104182 | \n", "\n", " |
| 451 | \n", "6.655388 | \n", "1.526366 | \n", "9.272764 | \n", "39.200870 | \n", "\n", " |
| 452 | \n", "6.792230 | \n", "1.514574 | \n", "9.194376 | \n", "39.291050 | \n", "\n", " |
| 453 | \n", "6.929072 | \n", "1.503631 | \n", "9.121214 | \n", "39.375155 | \n", "\n", " |
| 454 | \n", "7.134334 | \n", "1.487983 | \n", "9.019168 | \n", "39.492848 | \n", "last reaction step | \n", "
455 rows × 5 columns
\n", "