<jupyter_start><jupyter_text>Warm-up examples<jupyter_code>%matplotlib inline
from stimator import read_model
from ipywidgets import interact
from matplotlib import pyplot as plt
import seaborn as sns

from classhelper import tc2df

styles = ['seaborn-whitegrid', 'seaborn-poster']<jupyter_output><empty_output><jupyter_text>Closed system, reversible Michaelis-Menten enzymeA ⇄ P, catalyzed by an enzyme with kinetics $v = (V \cdot (A - \frac{P}{K_{eq}}))\:/\: (1 + \frac{A}{K_{mA}} + \frac{P}{K_{mP}})$ ![](images/closed.png)<jupyter_code>model = read_model("""
title Closed system, reversible Michaelis-Menten enzyme

v1: A -> P, (V * (A - P / Keq)) / (1 + A/KmA + P/KmP)

V = 1
Keq = 2

KmA = 2
KmP = 1

init: A = 12, P = 0

""")
result = model.solve(tf=40)
tc2df(result)
model.solve(tf=40).plot(fig_size=(12,8), style=styles)<jupyter_output><empty_output><jupyter_text>Changing parameters- the initial value of A - the value of KmA<jupyter_code>@interact(A=(6, 12, 0.5), KmA=(1, 5, 0.1))
def change_A(A=12, KmA=2):
    model.init.A = A
    model.parameters.KmA = KmA
    model.solve(tf=40).plot(fig_size=(12,8), yrange=(0,12), style=styles)
    plt.show()<jupyter_output><empty_output><jupyter_text>Closed system, several reversible Michaelis-Menten enzymes ![](images/closed_multi.png)<jupyter_code>model = read_model("""
title Linear pathway

v1: A -> B, (V * (A - B / Keq)) / (1 + A/KmA + B/KmB), V = 1, Keq = 2, KmA = 2, KmB = 1
v2: B -> C, (V * (B - C / Keq)) / (1 + B/KmB + C/KmC), V = 0.5, Keq = 2, KmB = 2, KmC = 1
v3: C -> D, (V * (C - D / Keq)) / (1 + C/KmC + D/KmD), V = 1, Keq = 2, KmC = 2, KmD = 1

init: A = 12

""")
model.solve(tf=150).plot(fig_size=(12,8), style=styles)
steady_state = model.solve(tf=2000).last

steady_state
A, B, C, D = steady_state['A'], steady_state['B'], steady_state['C'], steady_state['D']

r1 = B/A
r2 = C/B
r3 = D/C

print(f'B/A = {r1:.2f}')
print(f'C/B = {r2:.2f}')
print(f'D/C = {r3:.2f}')<jupyter_output><empty_output><jupyter_text>Open system, several reversible Michaelis-Menten enzymes (metabolic pathway) ![](images/open_linear.png)<jupyter_code>model = read_model("""
title Linear pathway

v1: A -> B, (V * (A - B / Keq)) / (1 + A/KmA + B/KmB), V = 1, Keq = 2, KmA = 2, KmB = 1
v2: B -> C, (V * (B - C / Keq)) / (1 + B/KmB + C/KmC), V = 0.5, Keq = 2, KmB = 2, KmC = 1
v3: C -> D, (V * (C - D / Keq)) / (1 + C/KmC + D/KmD), V = 1, Keq = 2, KmC = 2, KmD = 1

vAin  : -> A, kin, kin = 1
vAout : A ->, koutA * A, koutA = 1

vout  : D ->, kout * D, kout = 2
""")
model.solve(tf=20).plot(fig_size=(12,8), style=styles)<jupyter_output><empty_output><jupyter_text>&ReverseEquilibrium; A ⇄ B ⇄ C ⇄ D &rarr;, computing the values at **steady-state**<jupyter_code>steady_state = model.solve(tf=2000).last

steady_state
A, B, C, D = steady_state['A'], steady_state['B'], steady_state['C'], steady_state['D']

r1 = B/A
r2 = C/B
r3 = D/C

print(f'B/A = {r1:.2f}')
print(f'C/B = {r2:.2f}')
print(f'D/C = {r3:.2f}')<jupyter_output><empty_output><jupyter_text>&ReverseEquilibrium; A ⇄ B ⇄ C ⇄ D &rarr;, computing the rates of reactions at **steady-state**<jupyter_code>steady_state = model.solve(tf=20, outputs='>>').plot(fig_size=(12,8), style=styles)<jupyter_output><empty_output><jupyter_text>Changing the parameter $kin$ (rate of input of A into the pathway)<jupyter_code>@interact(kin=(1, 5, 0.2))
def change_kin(kin=1):
    model.parameters.vAin.kin = kin
    model.solve(tf=20).plot(fig_size=(12,8), yrange=(0,4), style=styles)<jupyter_output><empty_output><jupyter_text>Changing the parameter $kin$ (rate of input of A into the pathway), but displying the rates of reactions<jupyter_code>@interact(kin=(1, 5, 0.2))
def change_kin(kin=1):
    model.parameters.vAin.kin = kin
    model.solve(tf=20, outputs='v1 v2 v3'.split()).plot(fig_size=(12,8), yrange=(0,1), style=styles)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19485580670303976, 'fraction_numerical': 0.03923096908287867, 'mean_word_length': 4.563583815028902, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '472431', 'license': 'MIT', 'n_tokens_mistral': 1841, 'n_tokens_neox': 1715, 'n_words': 389, 'path': 'warm-up.ipynb', 'repo_name': 'aeferreira/simulationODE_examples', 'size': '3849'}