<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Glycolysis Model and Metabolic Control Analysis
Step1:  A Simple Model of the Glycolysis of Human Erythrocytes
This is a model for the glycolysis of human erythrocytes which takes into account ATP-synthesis and -consumption.
This model is based on the model introduced in the following publications
Step2:  The model consists of seven reactions and is at the steady state.
Step3:  Metabolic Control Analysis
Step4:  First of all, get_stoichiometry gives a stoichiometry matrix from the given species and reactions as follows
Step5:  The evaluate method of ode.ODEWorld returns current fluxes of the given reactions.
Step6:  ode.ODESimulator has methods for the fundamental properties related to metabolic control analysis.
Step7:  ode.ODESimulator also provides a stoichiometry matrix and fluxes.
Step8:  These properties satisfy some relations at the steady state.
$\frac{\mathrm{d}}{\mathrm{d}t}\mathbf{x} = \mathbf{S} \mathbf{v}$
Step9:  $\mathbf{J} = \frac{\mathrm{d}^2}{\mathrm{d}t^2}\mathbf{x} = \mathbf{S}\left(\frac{\mathrm{d}}{\mathrm{d}t}\mathbf{v}\right) = \mathbf{S} \mathbf{E}$
Step10:  Next, the ecell4.mca submodule provides useful functions for metabolic network and control analyses.
Step11:  generate_full_rank_matrix gives square matrix to be full rank. In this model, 5 out of 8 reactions are independent.
Step12:  The original stoichiometry matrix can be reproduced from these reduced matrices
Step13:  Finally, ecell4.mca provides two functions, unscaled_control_coefficients and scaled_control_coefficients, which calculate concentration and flux control coefficients from stoichiometry and elasticity matrices.
Step14:  Unscaled control coefficients satisfies connectivity theorem
Step15:  and
Step16:  On the other hand, scaled control coefficients
Step17:  satisfies summation theorem
Step18:  and
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from ecell4.prelude import *
Explanation: Glycolysis Model and Metabolic Control Analysis
End of explanation
citation(125616)
citation(168932)
Explanation: A Simple Model of the Glycolysis of Human Erythrocytes
This is a model for the glycolysis of human erythrocytes which takes into account ATP-synthesis and -consumption.
This model is based on the model introduced in the following publications:
End of explanation
with reaction_rules():
    2 * ATP > 2 * A13P2G + 2 * ADP | (3.2 * ATP / (1.0 + (ATP / 1.0) ** 4.0))
    A13P2G > A23P2G | 1500
    A23P2G > PEP | 0.15
    A13P2G + ADP > PEP + ATP | 1.57e+4
    PEP + ADP > ATP | 559
    # AMP + ATP > 2 * ADP | (1.0 * (AMP * ATP - 2.0 * ADP * ADP))
    AMP + ATP > 2 * ADP | 1.0 * AMP * ATP
    2 * ADP > AMP + ATP | 2.0 * ADP * ADP
    ATP > ADP | 1.46
m = get_model()
show(m)
y0 = {"A13P2G": 0.0005082, "A23P2G": 5.0834, "PEP": 0.020502,
      "AMP": 0.080139, "ADP": 0.2190, "ATP": 1.196867}
ret = run_simulation(100, model=m, y0=y0)
ret
Explanation: The model consists of seven reactions and is at the steady state.
End of explanation
import numpy
w = ret.world
sim = ode.Simulator(w, m)
Explanation: Metabolic Control Analysis
End of explanation
numpy.array(get_stoichiometry(m.list_species(), m.reaction_rules()))
Explanation: First of all, get_stoichiometry gives a stoichiometry matrix from the given species and reactions as follows:
End of explanation
numpy.array(w.evaluate(m.reaction_rules()))
Explanation: The evaluate method of ode.ODEWorld returns current fluxes of the given reactions.
End of explanation
x = numpy.array(sim.values())
x
dxdt = numpy.array(sim.derivatives())
dxdt
J = numpy.array(sim.jacobian())
J
E = numpy.array(sim.elasticity())
E
Explanation: ode.ODESimulator has methods for the fundamental properties related to metabolic control analysis.
End of explanation
S = numpy.array(sim.stoichiometry())
S
v = numpy.array(sim.fluxes())
v
Explanation: ode.ODESimulator also provides a stoichiometry matrix and fluxes.
End of explanation
numpy.isclose(dxdt, S @ v)
Explanation: These properties satisfy some relations at the steady state.
$\frac{\mathrm{d}}{\mathrm{d}t}\mathbf{x} = \mathbf{S} \mathbf{v}$
End of explanation
numpy.isclose(J, S @ E)
Explanation: $\mathbf{J} = \frac{\mathrm{d}^2}{\mathrm{d}t^2}\mathbf{x} = \mathbf{S}\left(\frac{\mathrm{d}}{\mathrm{d}t}\mathbf{v}\right) = \mathbf{S} \mathbf{E}$
End of explanation
from ecell4.mca import *
Explanation: Next, the ecell4.mca submodule provides useful functions for metabolic network and control analyses.
End of explanation
(link_matrix, kernel_matrix, independent_list) = generate_full_rank_matrix(S)
print(link_matrix)
print(kernel_matrix)
print(independent_list)
reduced_matrix = numpy.take(S, independent_list, 0)
reduced_matrix
Explanation: generate_full_rank_matrix gives square matrix to be full rank. In this model, 5 out of 8 reactions are independent.
End of explanation
S == link_matrix @ reduced_matrix
0 == S @ kernel_matrix
Explanation: The original stoichiometry matrix can be reproduced from these reduced matrices:
End of explanation
ccc, fcc = unscaled_control_coefficients(S, E)
print(ccc)
print(fcc)
Explanation: Finally, ecell4.mca provides two functions, unscaled_control_coefficients and scaled_control_coefficients, which calculate concentration and flux control coefficients from stoichiometry and elasticity matrices.
End of explanation
numpy.isclose(fcc @ (E @ link_matrix), 0)
Explanation: Unscaled control coefficients satisfies connectivity theorem:
End of explanation
numpy.isclose(numpy.take(ccc, independent_list, 0) @ (E @ link_matrix), -numpy.identity(link_matrix.shape[1]))
Explanation: and
End of explanation
ccc, fcc = scaled_control_coefficients(S, E, v, x)
print(ccc)
print(fcc)
Explanation: On the other hand, scaled control coefficients
End of explanation
numpy.isclose(ccc.sum(axis=1), 0)
Explanation: satisfies summation theorem:
End of explanation
numpy.isclose(fcc.sum(axis=1), 1)
Explanation: and
End of explanation
<END_TASK>