{ "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: Feb. 5, 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": "13e55c1d-609f-4bf0-a004-6c45bcfcbc99", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Added 'D:\\Docs\\- MY CODE\\BioSimulations\\life123-Win7' to sys.path\n" ] } ], "source": [ "# Extend the sys.path variable, to contain the project's root directory\n", "import set_path\n", "set_path.add_ancestor_dir_to_syspath(2) # The number of levels to go up \n", " # to reach the project's home, from the folder containing this notebook" ] }, { "cell_type": "code", "execution_count": 2, "id": "bdad128a-9214-46f5-aeb9-a7b77c81aa3e", "metadata": { "tags": [] }, "outputs": [], "source": [ "from experiments.get_notebook_info import get_notebook_basename\n", "\n", "from src.modules.reactions.reaction_data import ReactionData as chem\n", "from src.modules.reactions.reaction_dynamics import ReactionDynamics\n", "\n", "import numpy as np\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": "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.69 / K = 6) | 1st order in all reactants & products\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" ] } ], "source": [ "dynamics = ReactionDynamics(reaction_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": [ "single_compartment_react(): setting abs_fast_threshold to 250.0\n", "50 total step(s) taken\n" ] } ], "source": [ "dynamics.set_diagnostics() # To save diagnostic information about the call to single_compartment_react()\n", "#dynamics.verbose_list = [1, 2, 3] # Uncomment for detailed run information (meant for debugging the adaptive variable time step)\n", "\n", "# The changes of concentrations vary very rapidly early on; \n", "# so, we'll be using the dynamic_substeps option to increase time resolution,\n", "# as long as the reaction remains \"fast\" (based on a threshold of % change, as specified by fast_threshold)\n", "dynamics.single_compartment_react(time_step=0.001, reaction_duration=0.05,\n", " snapshots={\"initial_caption\": \"1st reaction step\",\n", " \"final_caption\": \"last reaction step\"},\n", " dynamic_substeps=4, rel_fast_threshold=25)" ] }, { "cell_type": "code", "execution_count": 7, "id": "5d1d3422-eeb1-4664-8d0e-3e56392ee3c4", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | SYSTEM TIME | \n", "A | \n", "B | \n", "caption | \n", "
|---|---|---|---|---|
| 0 | \n", "0.00000 | \n", "50.000000 | \n", "0.000000 | \n", "Initial state | \n", "
| 1 | \n", "0.00025 | \n", "49.625000 | \n", "0.375000 | \n", "Interm. step, due to the fast rxns: [0] | \n", "
| 2 | \n", "0.00050 | \n", "49.253281 | \n", "0.746719 | \n", "Interm. step, due to the fast rxns: [0] | \n", "
| 3 | \n", "0.00075 | \n", "48.884815 | \n", "1.115185 | \n", "Interm. step, due to the fast rxns: [0] | \n", "
| 4 | \n", "0.00100 | \n", "48.519573 | \n", "1.480427 | \n", "1st reaction step | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 196 | \n", "0.04900 | \n", "14.797598 | \n", "35.202402 | \n", "\n", " |
| 197 | \n", "0.04925 | \n", "14.730619 | \n", "35.269381 | \n", "Interm. step, due to the fast rxns: [0] | \n", "
| 198 | \n", "0.04950 | \n", "14.664226 | \n", "35.335774 | \n", "Interm. step, due to the fast rxns: [0] | \n", "
| 199 | \n", "0.04975 | \n", "14.598414 | \n", "35.401586 | \n", "Interm. step, due to the fast rxns: [0] | \n", "
| 200 | \n", "0.05000 | \n", "14.533178 | \n", "35.466822 | \n", "last reaction step | \n", "
201 rows × 4 columns
\n", "| \n", " | SYSTEM TIME | \n", "A | \n", "B | \n", "caption | \n", "
|---|---|---|---|---|
| 0 | \n", "0.00000 | \n", "50.000000 | \n", "0.000000 | \n", "Initial state | \n", "
| 1 | \n", "0.00025 | \n", "49.625000 | \n", "0.375000 | \n", "Interm. step, due to the fast rxns: [0] | \n", "
| 2 | \n", "0.00050 | \n", "49.253281 | \n", "0.746719 | \n", "Interm. step, due to the fast rxns: [0] | \n", "
| 3 | \n", "0.00075 | \n", "48.884815 | \n", "1.115185 | \n", "Interm. step, due to the fast rxns: [0] | \n", "
| 4 | \n", "0.00100 | \n", "48.519573 | \n", "1.480427 | \n", "1st reaction step | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 393 | \n", "0.29200 | \n", "7.144047 | \n", "42.855953 | \n", "\n", " |
| 394 | \n", "0.29400 | \n", "7.143964 | \n", "42.856036 | \n", "\n", " |
| 395 | \n", "0.29600 | \n", "7.143886 | \n", "42.856114 | \n", "\n", " |
| 396 | \n", "0.29800 | \n", "7.143814 | \n", "42.856186 | \n", "\n", " |
| 397 | \n", "0.30000 | \n", "7.143747 | \n", "42.856253 | \n", "last reaction step | \n", "
398 rows × 4 columns
\n", "| \n", " | SYSTEM TIME | \n", "A | \n", "B | \n", "S | \n", "caption | \n", "
|---|---|---|---|---|---|
| 0 | \n", "0.00000 | \n", "50.000000 | \n", "0.000000 | \n", "0.000000 | \n", "Initial state | \n", "
| 1 | \n", "0.00025 | \n", "47.750000 | \n", "0.375000 | \n", "1.875000 | \n", "Interm. step, due to the fast rxns: [0, 1] | \n", "
| 2 | \n", "0.00050 | \n", "45.648594 | \n", "0.732656 | \n", "3.618750 | \n", "Interm. step, due to the fast rxns: [0, 1] | \n", "
| 3 | \n", "0.00075 | \n", "43.685792 | \n", "1.074105 | \n", "5.240104 | \n", "Interm. step, due to the fast rxns: [0, 1] | \n", "
| 4 | \n", "0.00100 | \n", "41.852276 | \n", "1.400406 | \n", "6.747318 | \n", "1st reaction step | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 465 | \n", "0.29200 | \n", "5.990345 | \n", "34.993770 | \n", "9.015885 | \n", "\n", " |
| 466 | \n", "0.29400 | \n", "5.986936 | \n", "35.003253 | \n", "9.009812 | \n", "\n", " |
| 467 | \n", "0.29600 | \n", "5.983634 | \n", "35.012436 | \n", "9.003930 | \n", "\n", " |
| 468 | \n", "0.29800 | \n", "5.980436 | \n", "35.021330 | \n", "8.998234 | \n", "\n", " |
| 469 | \n", "0.30000 | \n", "5.977339 | \n", "35.029943 | \n", "8.992718 | \n", "last reaction step | \n", "
470 rows × 5 columns
\n", "| \n", " | SYSTEM TIME | \n", "A | \n", "B | \n", "S | \n", "caption | \n", "
|---|---|---|---|---|---|
| 0 | \n", "0.000 | \n", "50.000000 | \n", "0.000000 | \n", "0.000000 | \n", "Initial state | \n", "
| 1 | \n", "0.001 | \n", "48.350000 | \n", "1.500000 | \n", "0.150000 | \n", "Interm. step, due to the fast rxns: [0, 1] | \n", "
| 2 | \n", "0.002 | \n", "46.761965 | \n", "2.943000 | \n", "0.295035 | \n", "Interm. step, due to the fast rxns: [0, 1] | \n", "
| 3 | \n", "0.003 | \n", "45.233565 | \n", "4.331144 | \n", "0.435291 | \n", "Interm. step, due to the fast rxns: [0, 1] | \n", "
| 4 | \n", "0.004 | \n", "43.762556 | \n", "5.666495 | \n", "0.570949 | \n", "Interm. step, due to the fast rxns: [0, 1] | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 275 | \n", "6.850 | \n", "1.511216 | \n", "9.171961 | \n", "39.316824 | \n", "Interm. step, due to the fast rxns: [0, 1] | \n", "
| 276 | \n", "6.900 | \n", "1.507284 | \n", "9.145794 | \n", "39.346922 | \n", "Interm. step, due to the fast rxns: [0, 1] | \n", "
| 277 | \n", "6.950 | \n", "1.503449 | \n", "9.120272 | \n", "39.376280 | \n", "Interm. step, due to the fast rxns: [0, 1] | \n", "
| 278 | \n", "7.000 | \n", "1.499708 | \n", "9.095377 | \n", "39.404916 | \n", "Interm. step, due to the fast rxns: [0, 1] | \n", "
| 279 | \n", "7.050 | \n", "1.496059 | \n", "9.071094 | \n", "39.432847 | \n", "last reaction step | \n", "
280 rows × 5 columns
\n", "