{
"cells": [
{
"cell_type": "markdown",
"id": "49bcb5b0-f19d-4b96-a5f1-e0ae30f66d8f",
"metadata": {},
"source": [
"## Macromolecules : Binding Affinity and Fractional Occupancy, and regulation of the rates of reactions catalyzed by the macromolecule\n",
"\n",
"### Reaction `A <-> B` catalyzed when ligand `L` binds to `site 1` of macromolecule `M1`\n",
"\n",
"LAST REVISED: July 22, 2023"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "98adb66e-e336-4a4e-9a47-d48e9f0c8c68",
"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": "c1ac7763",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from src.modules.chemicals.chem_data import ChemData\n",
"from src.modules.reactions.reaction_dynamics import ReactionDynamics\n",
"#from src.modules.movies.movies import MovieTabular\n",
"\n",
"#import numpy as np\n",
"\n",
"import plotly.express as px"
]
},
{
"cell_type": "markdown",
"id": "1b3df8ff-f3b2-4d16-a04a-9f3675b79009",
"metadata": {},
"source": [
"# PART 1 - Consider just the un-catalyzed reaction `A <-> B` by itself"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "34e5c78b-c23a-47c1-8db0-0e2f997dcff6",
"metadata": {
"lines_to_next_cell": 2
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Number of reactions: 1 (at temp. 25 C)\n",
"0: A <-> B (kF = 1 / kR = 0.133057 / Delta_G = -5,000 / K = 7.51557) | 1st order in all reactants & products\n",
"Set of chemicals involved in the above reactions (not counting enzymes): {'A', 'B'}\n"
]
}
],
"source": [
"# Initialize the system\n",
"chem1 = ChemData(names=[\"A\", \"B\"])\n",
"\n",
"# Reaction A <-> B , without catalysis (slow forward rate)\n",
"chem1.add_reaction(reactants=\"A\", products=\"B\",\n",
" forward_rate=1. , delta_G= -5000)\n",
"\n",
"chem1.describe_reactions()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "d407238e-3961-48ec-9188-39f61e17ead6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SYSTEM STATE at Time t = 0:\n",
"2 species:\n",
" Species 0 (A). Conc: 100.0\n",
" Species 1 (B). Conc: 20.0\n",
"Set of chemicals involved in reactions (not counting enzymes): {'A', 'B'}\n"
]
}
],
"source": [
"# Set the initial concentrations of all the chemicals\n",
"dynamics1 = ReactionDynamics(chem_data=chem1)\n",
"\n",
"dynamics1.set_conc(conc={\"A\": 100., \"B\": 20.},\n",
" snapshot=True)\n",
"\n",
"dynamics1.describe_state()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "eed45215-960f-4fc5-b8b0-d3353fe2eecd",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* INFO: the tentative time step (0.02) leads to a least one norm value > its ABORT threshold:\n",
" -> will backtrack, and re-do step with a SMALLER delta time, multiplied by 0.4 (set to 0.008) [Step started at t=0, and will rewind there]\n",
"80 total step(s) taken\n"
]
}
],
"source": [
"# Take the system to equilibrium\n",
"dynamics1.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",
"dynamics1.set_thresholds(norm=\"norm_A\", low=0.6, high=1.0, abort=1.44)\n",
"dynamics1.set_thresholds(norm=\"norm_B\", low=0.04, high=0.6, abort=1.5)\n",
"dynamics1.set_step_factors(upshift=1.2, downshift=0.7, abort=0.4)\n",
"dynamics1.set_error_step_factor(0.3)\n",
"\n",
"dynamics1.single_compartment_react(initial_step=0.02, reaction_duration=4.0,\n",
" variable_steps=True, explain_variable_steps=False)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "bb527a31-2e90-401e-b310-cfaa5c06b8e0",
"metadata": {},
"outputs": [],
"source": [
"#dynamics1.explain_time_advance()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "097d3abf-397b-495c-85e9-214cb34698a1",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
" \n",
" "
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"hovertemplate": "Chemical=A
SYSTEM TIME=%{x}
concentration=%{y}
SYSTEM TIME=%{x}
concentration=%{y}