-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathODEmodel_parameter_sampling_all_logics.py
184 lines (144 loc) · 6.32 KB
/
ODEmodel_parameter_sampling_all_logics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 27 08:58:00 2019
@author: MLempp
"""
import numpy as np
from scipy.integrate import odeint, ode
from scipy.misc import derivative
import matplotlib.pyplot as plt
from random import sample
from numpy import linalg
import sympy as sp
import seaborn as sns
import matplotlib.cm as cm
from datetime import date
from datetime import datetime as timer
from ODEmodel_parameter_sampling_utils import ODEmodel, jac, loguniform
# =============================================================================
# define parameter ranges and run 5000 parameter samplings
# =============================================================================
N = 1000
setss = [ ['1' , '(m1)/((m1)+kt1)' , '(kt1)/((m1)+kt1)'], #b1
['1' , '(m1)/((m1)+kt2)' , '(kt2)/((m1)+kt2)']] #b2
stable_setting = {'m1':[],
'e1':[],
'e2':[],
'r1':[],
'r2':[],
'mue':[],
'kcat1':[],
'kcat2':[],
'Km1':[],
'Km2':[],
'ind':[],
'kt1':[],
'kt2':[],
'EV':[],
'set':[]}
instable_setting= {'m1':[],
'e1':[],
'e2':[],
'r1':[],
'r2':[],
'mue':[],
'kcat1':[],
'kcat2':[],
'Km1':[],
'Km2':[],
'ind':[],
'kt1':[],
'kt2':[],
'EV':[],
'set':[]}
z0 = [2.1, #m1
0.024, #e2
0.0] #e3
for a in setss[0]: #iterate through all logics for b1
for b in setss[1]: #iterate through all logics for b2
hsmf=[a,b]
print(hsmf)
strain = 'allLogics'
q = 0
while q < N:
kcat1 = np.random.uniform(15720, 16440)
kcat2 = np.random.uniform(1621, 1789)
Km1 = np.random.uniform(0.72, 1.06)
Km2 = np.random.uniform(0.48, 0.60)
ind = loguniform()
kt1 = np.random.uniform(1.5, 2.0)
kt2 = np.random.uniform(1.5, 2.0)
par = [87.5, #0 r0
kcat1, #1 kcat1
kcat2, #2 kcat2
Km1, #3 Km1
Km2, #4 Km2
0.00024, #5 beta1
0.00068, #6 beta1
ind, #7 ind
kt1, #8 kt1
kt2, #9 kt2
8750, #10 alpha
hsmf] #11 set (b1, b2)
x = 10000
t = np.linspace(0, x, num=(x*10)+1)
z1 = odeint(ODEmodel, z0, t, args=(par, ) )
J,SS = jac(z1, par)
EV = np.max(np.real(linalg.eig(J)[0]))
# check if steady state is reached
if np.sum(np.absolute(SS)) < 1e-08 and EV < -1e-08 and all(z1[:,0]>=0) and all(z1[:,1]>=0) and all(z1[:,2]>=0):
if q % 20 ==0:
print(q)
q += 1
m1 = z1[:,0]
e1 = z1[:,1]
e2 = z1[:,2]
r1 = par[1] * e1 * (m1/(m1+par[3]))
r2 = par[2] * e2 * (m1/(m1+par[4]))
mue = r1/par[10]
stable_setting['m1'].append(m1[-1])
stable_setting['e1'].append(e1[-1])
stable_setting['e2'].append(e2[-1])
stable_setting['r1'].append(r1[-1])
stable_setting['r2'].append(r2[-1])
stable_setting['mue'].append(mue[-1])
stable_setting['kcat1'].append(par[1])
stable_setting['kcat2'].append(par[2])
stable_setting['Km1'].append(par[3])
stable_setting['Km2'].append(par[4])
stable_setting['ind'].append(par[7])
stable_setting['kt1'].append(par[8])
stable_setting['kt2'].append(par[9])
stable_setting['EV'].append(EV)
stable_setting['set'].append(hsmf)
else:
m1 = z1[:,0]
e1 = z1[:,1]
e2 = z1[:,2]
r1 = par[1] * e1 * (m1/(m1+par[3]))
r2 = par[2] * e2 * (m1/(m1+par[4]))
mue = r1/par[10]
instable_setting['m1'].append(m1[-1])
instable_setting['e1'].append(e1[-1])
instable_setting['e2'].append(e2[-1])
instable_setting['r1'].append(r1[-1])
instable_setting['r2'].append(r2[-1])
instable_setting['mue'].append(mue[-1])
instable_setting['kcat1'].append(par[1])
instable_setting['kcat2'].append(par[2])
instable_setting['Km1'].append(par[3])
instable_setting['Km2'].append(par[4])
instable_setting['ind'].append(par[7])
instable_setting['kt1'].append(par[8])
instable_setting['kt2'].append(par[9])
instable_setting['EV'].append(EV)
instable_setting['set'].append(hsmf)
# =============================================================================
# save
# =============================================================================
today = date.today()
d3 = today.strftime("%y%m%d_")
d2 = timer.now().strftime('%H%M%S')
path = 'results/'
saving = path+d3+d2+'_parameters_'+strain+'_'+str(q)
np.save(saving, [stable_setting, instable_setting])