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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# %%
|
| 2 |
+
import numpy as np
|
| 3 |
+
import sympy as sp
|
| 4 |
+
from scipy.optimize import root_scalar
|
| 5 |
+
import ultraplot as uplt
|
| 6 |
+
from smitfit.symbol import Symbols
|
| 7 |
+
from smitfit.model import Model
|
| 8 |
+
import polars as pl
|
| 9 |
+
# %%
|
| 10 |
+
|
| 11 |
+
s = Symbols("TF1, TF2, TFR, R, T_TF, T_R, kD_MD, kD_MR", positive=True)
|
| 12 |
+
# %%
|
| 13 |
+
mb_ribosome = s.TFR + s.R - s.T_R # type: ignore
|
| 14 |
+
mb_TF = s.TF1 + 2 * s.TF2 + s.TFR - s.T_TF # type: ignore
|
| 15 |
+
eq_MD = s.TF1**2 - s.kD_MD * s.TF2 # type: ignore
|
| 16 |
+
eq_MR = (s.TF1 * s.R) - s.kD_MR * s.TFR # type: ignore
|
| 17 |
+
|
| 18 |
+
#
|
| 19 |
+
knowns = ["T_TF", "T_R", "kD_MD", "kD_MR"]
|
| 20 |
+
|
| 21 |
+
# solve for: TF1
|
| 22 |
+
# take Monomer-dimer equillibrium, put it in mass balance TF to eliminate TF2
|
| 23 |
+
sub_TF2 = (s.TF2, sp.solve(eq_MD, s.TF2)[0])
|
| 24 |
+
|
| 25 |
+
# same for monomer dimer, eliminate TF_R
|
| 26 |
+
sub_mb = (s.R, sp.solve(mb_ribosome, s.R)[0])
|
| 27 |
+
sub_TFR = (s.TFR, sp.solve(eq_MR.subs(*sub_mb), s.TFR)[0])
|
| 28 |
+
|
| 29 |
+
# we know have an expr to find free TF monomer
|
| 30 |
+
eq_TF1 = mb_TF.subs([sub_TF2, sub_TFR])
|
| 31 |
+
eq_TF1
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
# %%
|
| 35 |
+
|
| 36 |
+
d = {
|
| 37 |
+
s.TF2: sp.solve(eq_MD, s.TF2)[0],
|
| 38 |
+
s.TFR: sp.solve(mb_TF, s.TFR)[0],
|
| 39 |
+
s.R: sp.solve(mb_ribosome, s.R)[0],
|
| 40 |
+
}
|
| 41 |
+
m = Model(d)
|
| 42 |
+
|
| 43 |
+
# %%
|
| 44 |
+
|
| 45 |
+
ld = sp.lambdify([s.TF1] + [s[k] for k in knowns], eq_TF1)
|
| 46 |
+
|
| 47 |
+
# %%
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def solve_system(params: dict) -> dict:
|
| 51 |
+
args = tuple(params[k] for k in knowns)
|
| 52 |
+
# root find TF1
|
| 53 |
+
sol = root_scalar(ld, bracket=(0, params["T_TF"]), args=args)
|
| 54 |
+
# calculate the others
|
| 55 |
+
ans = m(**params, TF1=sol.root)
|
| 56 |
+
|
| 57 |
+
return {"TF1": sol.root, **ans}
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def make_df(records: list[dict]) -> pl.DataFrame:
|
| 61 |
+
df = pl.DataFrame(records)
|
| 62 |
+
cols = [
|
| 63 |
+
(pl.col("TF1") + pl.col("TF2") + pl.col("TFR")).alias("total TF"),
|
| 64 |
+
(pl.col("TFR") + pl.col("R")).alias("total R"),
|
| 65 |
+
]
|
| 66 |
+
df = df.with_columns(cols)
|
| 67 |
+
return df
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
# %%
|
| 71 |
+
# The concentration of TF exceeds that of ribosomes (∼50 μM and ∼30 μM, respectively)[12,13]
|
| 72 |
+
# TF binds free ribosomal 50S subunits with a Kd of ∼1 μM
|
| 73 |
+
# Purified TF forms dimers with a Kd of 1–2 μM (ref. 14).
|
| 74 |
+
# " Real-time observation of trigger factor function on translating ribosomes", https://doi.org/10.1038/nature05225
|
| 75 |
+
|
| 76 |
+
# "the cytosol contains 2.6 moles of trigger factor per mole of ribosomes. "
|
| 77 |
+
# The “trigger factor cycle” includes ribosomes, presecretory proteins, and the plasma membrane
|
| 78 |
+
#
|
| 79 |
+
|
| 80 |
+
ecoli_params = {
|
| 81 |
+
"T_TF": 50,
|
| 82 |
+
"T_R": 30,
|
| 83 |
+
"kD_MD": 1,
|
| 84 |
+
"kD_MR": 2,
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
solve_system(ecoli_params)
|
| 88 |
+
|
| 89 |
+
# %%
|
| 90 |
+
|
| 91 |
+
vmin, vmax = 1e-6, 1000e-6
|
| 92 |
+
total_tf_protomer = np.logspace(
|
| 93 |
+
0, 4, endpoint=True, num=100
|
| 94 |
+
) # total TF protomer from 1 uM to 1
|
| 95 |
+
|
| 96 |
+
input_params = [ecoli_params | {"T_TF": v} for v in total_tf_protomer]
|
| 97 |
+
input_params
|
| 98 |
+
|
| 99 |
+
# %%
|
| 100 |
+
output_records = [solve_system(params) for params in input_params]
|
| 101 |
+
df = make_df(output_records)
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
# %%
|
| 105 |
+
species = ["TF1", "TF2", "TFR"]
|
| 106 |
+
cycle = iter(uplt.Cycle("default"))
|
| 107 |
+
fig, axes = uplt.subplots(nrows=2, aspect=2.5, axwidth="120mm")
|
| 108 |
+
for s in species:
|
| 109 |
+
axes[0].plot(
|
| 110 |
+
total_tf_protomer,
|
| 111 |
+
df.select(pl.col(s) / pl.col("total TF")),
|
| 112 |
+
label=s,
|
| 113 |
+
**next(cycle),
|
| 114 |
+
)
|
| 115 |
+
|
| 116 |
+
axes[0].format(title="TF")
|
| 117 |
+
species = ["TFR", "R"]
|
| 118 |
+
for s in species:
|
| 119 |
+
axes[1].plot(
|
| 120 |
+
total_tf_protomer,
|
| 121 |
+
df.select(pl.col(s) / pl.col("total R")),
|
| 122 |
+
label=s,
|
| 123 |
+
**next(cycle),
|
| 124 |
+
)
|
| 125 |
+
axes[1].format(title="ribosome")
|
| 126 |
+
|
| 127 |
+
axes.format(
|
| 128 |
+
ylim=(0, 1),
|
| 129 |
+
xscale="log",
|
| 130 |
+
xformatter="sci",
|
| 131 |
+
ylabel="Fractional population",
|
| 132 |
+
xlabel="Total protomer TF (uM)",
|
| 133 |
+
)
|
| 134 |
+
axes.legend(loc="r", ncols=1)
|
| 135 |
+
|
| 136 |
+
# %%
|
| 137 |
+
# lets repeat for ribosome titration, fixed 100 nM TF protomer concentration
|
| 138 |
+
|
| 139 |
+
microscopy_params = {
|
| 140 |
+
"T_TF": 1, # 100 nM
|
| 141 |
+
"kD_MD": 1,
|
| 142 |
+
"kD_MR": 1,
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
# %%
|
| 146 |
+
|
| 147 |
+
total_ribosome = np.linspace(0, 5, endpoint=True)
|
| 148 |
+
input_params = [microscopy_params | {"T_R": v} for v in total_ribosome]
|
| 149 |
+
|
| 150 |
+
# %%
|
| 151 |
+
output_records = [solve_system(params) for params in input_params]
|
| 152 |
+
df = make_df(output_records)
|
| 153 |
+
|
| 154 |
+
# %%
|
| 155 |
+
species = ["TF1", "TF2", "TFR"]
|
| 156 |
+
cycle = iter(uplt.Cycle("default"))
|
| 157 |
+
|
| 158 |
+
fig, axes = uplt.subplots(nrows=2, aspect=2.5, axwidth="120mm")
|
| 159 |
+
for s in species:
|
| 160 |
+
axes[0].plot(
|
| 161 |
+
total_ribosome,
|
| 162 |
+
df.select(pl.col(s) / pl.col("total TF")),
|
| 163 |
+
label=s,
|
| 164 |
+
**next(cycle),
|
| 165 |
+
)
|
| 166 |
+
|
| 167 |
+
axes[0].format(title="TF")
|
| 168 |
+
|
| 169 |
+
species = ["TFR", "R"]
|
| 170 |
+
for s in species:
|
| 171 |
+
axes[1].plot(
|
| 172 |
+
total_ribosome,
|
| 173 |
+
df.select(pl.col(s) / pl.col("total R")),
|
| 174 |
+
label=s,
|
| 175 |
+
**next(cycle),
|
| 176 |
+
)
|
| 177 |
+
axes[1].format(title="ribosome")
|
| 178 |
+
|
| 179 |
+
axes.format(
|
| 180 |
+
ylim=(0, 1),
|
| 181 |
+
# xscale="log",
|
| 182 |
+
xformatter="sci",
|
| 183 |
+
ylabel="Fractional population",
|
| 184 |
+
xlabel="Total protomer TF (uM)",
|
| 185 |
+
)
|
| 186 |
+
axes.legend(loc="r", ncols=1)
|
| 187 |
+
|
| 188 |
+
# %%
|