From bb67e34f734deefd2fb6adcc05249dcbd7046e9b Mon Sep 17 00:00:00 2001 From: ralf Date: Thu, 8 Aug 2024 11:01:19 +0300 Subject: [PATCH] Applied good practice tips; Fixed typos in expressions in model.py --- Model.py | 139 ++++++++++++++++-------------- __pycache__/Model.cpython-311.pyc | Bin 15362 -> 15350 bytes fitter.py | 8 +- 3 files changed, 80 insertions(+), 67 deletions(-) diff --git a/Model.py b/Model.py index 50010aa..40b34bd 100644 --- a/Model.py +++ b/Model.py @@ -11,41 +11,45 @@ RT = R * T class Model: def __init__(self): - self.A_cap = 1.534e-4 # cm^2, Capacitive membrane area - self.C_mem = 1.0 # uF/cm2 Specific membrane capacitance - self.V_myo = 25.84e-6 # uL, Myoplasmic volume - self.current2flux = self.A_cap * self.C_mem / 2 / F # + self.A_cap: float = 1.534e-4 # cm^2, Capacitive membrane area + self.C_mem: float = 1.0 # uF/cm2 Specific membrane capacitance + self.V_myo: float = 25.84e-6 # uL, Myoplasmic volume + self.current2flux: float = self.A_cap * self.C_mem / 2 / F # - self.period = 1000 # ms, pulse period - self.V_mem_rest = -80.0 # mV, resting membrane potential + self.period: float = 1000 # ms, pulse period + self.V_mem_rest: float = -80.0 # mV, resting membrane potential - self.Nai = 11000 # uM, Myoplasmic Na+ concentration - self.Nao = 150000 # uM, Extracellular Na+ concentration + self.Nai: float = 11000 # uM, Myoplasmic Na+ concentration + self.Nao: float = 150000 # uM, Extracellular Na+ concentration - self.eta = 0.35 # Controls voltage dependance of Na/Ca2+ exchange + self.eta: float = 0.35 # Controls voltage dependance of Na/Ca2+ exchange - self.km_Na = 87500 # uM, Na+ half-saturation constant for Na+/Ca2+ exchange - self.k_sat = ( + self.km_Na: float = ( + 87500 # uM, Na+ half-saturation constant for Na+/Ca2+ exchange + ) + self.k_sat: float = ( 0.1 # Na+/Ca2+ exchange saturation factor at very negative potentials ) - self.km_Ca = (1380,) # uM, Ca2+ half-saturation constant for Na+/Ca2+ exchange - self.k_Na_Ca = 292.8 # pA/pF, Scaling factor of Na2+/Ca2+ exchange + self.km_Ca: float = ( + 1380 # uM, Ca2+ half-saturation constant for Na+/Ca2+ exchange + ) + self.k_Na_Ca: float = 292.8 # pA/pF, Scaling factor of Na2+/Ca2+ exchange - self.I_max_pCa = 1.0 # pA/pF, Maximum Ca2+ pump current + self.I_max_pCa: float = 1.0 # pA/pF, Maximum Ca2+ pump current # self.Cai = 0.1 # uM, Cytoplasmic Ca2+ concentration fixed at this point - self.LTRPN_tot = ( + self.LTRPN_tot: float = ( 70.0 # uM, Total myoplasmic troponin low-affinity site concentration ) - self.HTRPN_tot = ( + self.HTRPN_tot: float = ( 140.0 # uM, Total myoplasmic troponin high-affinity site concentration ) # self.LTRPNCa = 11.2684 # uM, Concentration Ca2+ bound low-affinity troponin-binding sites # self.HTRPNCa = 125.290 # uM, Concentration Ca2+ bound high-affinity troponin-binding sites - self.k_htrpn_positive = ( + self.k_htrpn_positive: float = ( 0.00237 # uM^(-1)/ms, Ca2+ on rate const. for troponin high-affinity sites ) self.k_htrpn_negative = ( @@ -55,65 +59,78 @@ class Model: self.k_ltrpn_positive = ( 0.0327 # uM^(-1)/ms, Ca2+ on rate const. for troponin low-affinity sites ) - self.k_ltrpn_negative = ( + self.k_ltrpn_negative: float = ( 0.0196 # ms, Ca2+ off rate const. for troponin low-affinity sites ) - self.CMDN_tot = 50 # uM, Total myoplasmic calmodulin concentration - self.Km_CMDN = 0.238 # uM, Ca2 half-saturation constant for calmodulin + self.CMDN_tot: float = 50 # uM, Total myoplasmic calmodulin concentration + self.Km_CMDN: float = 0.238 # uM, Ca2 half-saturation constant for calmodulin - self.nu_1 = 4.5 # 1/ms, Maximum RyR channel Ca2+ permeability Ca2+ leak rate constant from the NSR - self.nu_2 = 1.74e-5 # ms^(-1), Ca2+ leak rate const. from the NSR - self.nu_3 = 0.45 # uM/ms, SR Ca2+ -ATPase maximum pupmp rate + self.nu_1: float = ( + 4.5 # 1/ms, Maximum RyR channel Ca2+ permeability Ca2+ leak rate constant from the NSR + ) + self.nu_2: float = 1.74e-5 # ms^(-1), Ca2+ leak rate const. from the NSR + self.nu_3: float = 0.45 # uM/ms, SR Ca2+ -ATPase maximum pupmp rate - self.Km_up = 0.5 # uM, Half-saturation constant for SR Ca2+ -ATPase pump - self.km_p_ca = 0.5 # uM, Ca2+ half-saturation constant for Ca2+ pump current + self.Km_up: float = 0.5 # uM, Half-saturation constant for SR Ca2+ -ATPase pump + self.km_p_ca: float = ( + 0.5 # uM, Ca2+ half-saturation constant for Ca2+ pump current + ) # self.Ca_NSR = 1299.50 # uM,NSR Ca2+ concentration - self.tau_xfer = 8.0 # ms, Time constant for transfer from subspace to myoplasm + self.tau_xfer: float = ( + 8.0 # ms, Time constant for transfer from subspace to myoplasm + ) - self.K_pc_max = ( + self.K_pc_max: float = ( 0.23324 # 1/ms, Maximum time constant for Ca2+-induced inactivation ) - self.K_pc_half = ( + self.K_pc_half: float = ( 20.0 # uM, Half-saturation constant for Ca2+-induced inactivation ) - self.Kpcb = 0.0005 # 1/ms, Voltage-insensitive rate constant for inactivation - self.km_Ca = 1380 # uM, Ca2+ half-saturation constant for Na+/Ca2+ exchange + self.Kpcb: float = ( + 0.0005 # 1/ms, Voltage-insensitive rate constant for inactivation + ) - self.Gcab = 0.000367 # mS/uF + self.Gcab: float = 0.000367 # mS/uF - self.Cao = 1130.0 # uM, Ca2+ outside the cell - self.gCaL = ( + self.Cao: float = 1130.0 # uM, Ca2+ outside the cell + self.gCaL: float = ( 0.1729 # mS/uF, Specific maximum conductivity for L-type Ca2+ channel ) - self.ECaL = 43.0 # mV, Reversal potential for L-type Ca2 - self.V_ss = 1.485e-9 # uL, Dyadic aka subspace volume + self.ECaL: float = 43.0 # mV, Reversal potential for L-type Ca2 + self.V_ss: float = 1.485e-9 # uL, Dyadic aka subspace volume # self.Ca_JSR = 1299.50 # uM, JSR Ca2+ concentration - self.F_tot = 25 # uM, total concentration of Fluo-4 - self.k_on = 0.1 # 1/uM * 1/ms, Fluo-4 reaction rate constant - self.k_off = 0.11 # 1/ms, Fluo-4 reaction rate constant 2 + self.F_tot: float = 25 # uM, total concentration of Fluo-4 + self.k_on: float = 0.1 # 1/uM * 1/ms, Fluo-4 reaction rate constant + self.k_off: float = 0.11 # 1/ms, Fluo-4 reaction rate constant 2 - self.V_NSR = 2.098e-6 # ul, Network SR volume - self.tau_tr = 20 # ms, Time const for transfer from NSR to JSR + self.V_NSR: float = 2.098e-6 # ul, Network SR volume + self.tau_tr: float = 20 # ms, Time const for transfer from NSR to JSR - self.CSQN_tot = 15000.0 # uM, total junctional SR calsequestrin concentration - self.Km_CSQN = 800.0 # uM, Ca2 half-saturation constant for calsequestrin + self.CSQN_tot: float = ( + 15000.0 # uM, total junctional SR calsequestrin concentration + ) + self.Km_CSQN: float = ( + 800.0 # uM, Ca2 half-saturation constant for calsequestrin + ) - self.k_a_positive = 0.006075 # uM^(-4)/ms, RyR Pc1 - Po1 rate constant - self.k_a_negative = 0.07125 # 1/ms, RyR Po1 - Pc1 rate constant - self.k_b_positive = 0.00405 # uM^(-3)/ms, RyR Po1 - Po2 rate constant - self.k_b_negative = 0.965 # 1/ms, RyR Po2 - Po1 rate constant - self.k_c_positive = 0.009 # 1/ms, RyR Po1 - Pc2 rate constant - self.k_c_negative = 0.0008 # 1/ms, RyR Pc2 - Po1 rate constant + self.k_a_positive: float = 0.006075 # uM^(-4)/ms, RyR Pc1 - Po1 rate constant + self.k_a_negative: float = 0.07125 # 1/ms, RyR Po1 - Pc1 rate constant + self.k_b_positive: float = 0.00405 # uM^(-3)/ms, RyR Po1 - Po2 rate constant + self.k_b_negative: float = 0.965 # 1/ms, RyR Po2 - Po1 rate constant + self.k_c_positive: float = 0.009 # 1/ms, RyR Po1 - Pc2 rate constant + self.k_c_negative: float = 0.0008 # 1/ms, RyR Pc2 - Po1 rate constant - self.n_ryr = 4 # RyR Ca2+ cooperativity parameter Pc1 - Po1 - self.m_ryr = 3 # RyR Ca2+ cooperativity parameter Po1 - Po2 + self.n_ryr: int = 4 # RyR Ca2+ cooperativity parameter Pc1 - Po1 + self.m_ryr: int = 3 # RyR Ca2+ cooperativity parameter Po1 - Po2 - self.I_CaL_max = 7.0 # pA/pF, normalization constant for L-type Ca2+ current - self.V_JSR = 0.12e-6 # ul, Junctional SR volume + self.I_CaL_max: float = ( + 7.0 # pA/pF, normalization constant for L-type Ca2+ current + ) + self.V_JSR: float = 0.12e-6 # ul, Junctional SR volume def ode_system(self, t, states): @@ -194,9 +211,6 @@ class Model: - 4 * beta * self.Kpcb * I3 ) - # Bi = (1 + (self.CMDN_tot * self.Km_CMDN)/(self.Km_CMDN+(Cai))**2)**(-1) - # Bss = 1 / ((self.CMDN_tot * self.Km_CMDN) / (self.Km_CMDN + Cass) ** 2) - Bi = 1 / (1 + (self.CMDN_tot * self.Km_CMDN) / (self.Km_CMDN + Cai) ** 2) Bss = 1 / (1 + (self.CMDN_tot * self.Km_CMDN) / (self.Km_CMDN + Cass) ** 2) @@ -253,7 +267,7 @@ class Model: P_C1 = 1 - (P_C2 + P_O1 + P_O2) dP_O1dt = self.k_a_positive * (Cass) ** self.n_ryr * P_C1 - -self.k_a_negative * P_O1 - self.k_a_positive * (Cass) ** self.m_ryr * P_O1 + -self.k_a_negative * P_O1 - self.k_b_positive * (Cass) ** self.m_ryr * P_O1 +self.k_b_negative * P_O2 - self.k_c_positive * P_O1 + self.k_c_negative * P_C2 dP_O2dt = ( @@ -269,7 +283,7 @@ class Model: dOsdt = alpha * C4 - 4 * beta * Os + self.Kpcb * I1 -gamma * Os + 0.001 * (alpha * I2 - Kpcf * Os) - ECaN = (R * T) / F * np.log(self.Cao / Cai) + ECaN = (R * T) / (2 * F) * np.log(self.Cao / Cai) I_Cab = self.Gcab * (V - ECaN) @@ -326,8 +340,10 @@ class Model: return np.where((t0 + n <= t) & (t < t1 + n), v1, self.V_mem_rest) def get_initial_values(self): - Cai_0 = 0.11712 # Cai - FCa_0 = (self.k_on * self.F_tot * Cai_0) / (self.k_on * Cai_0 + self.k_off) + Cai_0: float = 0.11712 # Cai + FCa_0: float = (self.k_on * self.F_tot * Cai_0) / ( + self.k_on * Cai_0 + self.k_off + ) return [ Cai_0, # Cass 0.930308e-18, # Os, @@ -362,9 +378,6 @@ class Model: ) r.set_initial_value(initial_values, times[0]) - #states = np.array([[0.0] * times.size] * len(initial_values)) - #states[:, 0] = initial_values - states = np.zeros((len(initial_values), times.size)) states[:, 0] = initial_values @@ -427,7 +440,7 @@ if __name__ == "__main__": Cai_0 = 0.11712 # Cai FCa_0 = (model.k_on * model.F_tot * Cai_0) / (model.k_on * Cai_0 + model.k_off) - print(FCa_0) + # print(FCa_0) # Cass, Os, C2, C3, C4, I1, I2, I3, LTRPNCa, HTRPNCa, Ca_NSR, Ca_JSR, P_RyR, P_O1, P_O2, P_C2, Cai, FCa = states initial_values = [ diff --git a/__pycache__/Model.cpython-311.pyc b/__pycache__/Model.cpython-311.pyc index 21ab7463c5fcfe233f721626b24df5d9b809e6a6..b83e4405540e9b8d55edcbc3cc6ddf2dc2f28e25 100644 GIT binary patch delta 2376 zcmZvcZERCj7{~AF?Je!?%er+NUDvf8?bh9Hl(s7`8!#p>4kjRM1o?p0;tCAAZaE!; z)tW9w!#+%5oRC291(O*?MTx~k6a6TOADfWa+z6ILqb8bk#u(!#pXc7~GG1=e-+BJe zx#v9RIp;k0wX^@6v3+Q@iX1%c)3=V_-#Tw|lJ@!Fi{#k+?6Hd^C^%BqYxV4YxL%iX zu^Q*EF+ zG}R7DDrhnYGNh>vP@S5RKy_&<1Zu6OIzfds)dgyurq+UrXetaUs;PCLV%)|hJrV)g zt#w90#WfWJwO&))Fei1hpm2bUvYc?G=rkDkf={ec#oV{M%>scZ^MymR5MtTyAZLrl#V;VaBq{hfT%h!KP~9taVkMGg;@v zs*$tWSJ<`7wn5~)7|T-e`Po&|aKX0*l(p>fqZ6lC8fF69jZRa!8H1TB>QXC~8g(v9 z)uz2{t%{trUiDis_EJ0>+78uk0$WMiR9RZK1y)KtHb@>M6 zj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