-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBoolean_test.py
222 lines (202 loc) · 6.13 KB
/
Boolean_test.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# Boolean SPN model from Albert and Othmer 2002
from boolean2 import Model
import numpy as np
import matplotlib.pyplot as plt
rules = """
SLP_1 = False
wg_mRNA_1 = False
WG_1 = False
en_mRNA_1 = True
EN_1 = False
hh_mRNA_1 = True
HH_1 = False
ptc_mRNA_1 = False
PTC_1 = False
PH_1 = False
SMO_1 = False
#===============================================================================
ci_mRNA_1 = False
CI_1 = False
CIA_1 = False
CIR_1 = False
#===============================================================================
#===============================================================================
SLP_2 = False
wg_mRNA_2 = False
WG_2 = False
en_mRNA_2 = False
EN_2 = False
hh_mRNA_2 = False
HH_2 = False
ptc_mRNA_2 = True
PTC_2 = False
PH_2 = False
SMO_2 = False
ci_mRNA_2 = True
CI_2 = False
CIA_2 = False
CIR_2 = False
#
SLP_3 = True
wg_mRNA_3 = False
WG_3 = False
en_mRNA_3 = False
EN_3 = False
hh_mRNA_3 = False
HH_3 = False
ptc_mRNA_3 = True
PTC_3 = False
PH_3 = False
SMO_3 = False
ci_mRNA_3 = True
CI_3 = False
CIA_3 = False
CIR_3 = False
#
SLP_4 = True
wg_mRNA_4 = True
WG_4 = False
en_mRNA_4 = False
EN_4 = False
hh_mRNA_4 = False
HH_4 = False
ptc_mRNA_4 = True
PTC_4 = False
PH_4 = False
SMO_4 = False
ci_mRNA_4 = True
CI_4 = False
CIA_4 = False
CIR_4 = False
#===============================================================================
SLP_1* = SLP_1
wg_mRNA_1* = (CIA_1 and SLP_1 and not CIR_1) or (wg_mRNA_1 and (CIA_1 or SLP_1) and not CIR_1)
WG_1* = wg_mRNA_1
en_mRNA_1* = (WG_4 or WG_2) and not SLP_1
EN_1* = en_mRNA_1
hh_mRNA_1* = EN_1 and not CIR_1
HH_1* = hh_mRNA_1
ptc_mRNA_1* = CIA_1 and not EN_1 and not CIR_1
PTC_1* = ptc_mRNA_1 or (PTC_1 and not HH_4 and not HH_2)
PH_1* = (ptc_mRNA_1 or (PTC_1 and not HH_4 and not HH_2)) and (hh_mRNA_4 or hh_mRNA_2)
SMO_1* = not (ptc_mRNA_1 or (PTC_1 and not HH_4 and not HH_2)) or hh_mRNA_4 or hh_mRNA_2
ci_mRNA_1* = not EN_1
CI_1* = ci_mRNA_1
CIA_1* = CI_1 and (SMO_1 or hh_mRNA_4 or hh_mRNA_2)
CIR_1* = CI_1 and not SMO_1 and not hh_mRNA_4 and not hh_mRNA_2
SLP_2* = SLP_2
wg_mRNA_2* = (CIA_2 and SLP_2 and not CIR_2) or (wg_mRNA_2 and (CIA_2 or SLP_2) and not CIR_2)
WG_2* = wg_mRNA_2
en_mRNA_2* = (WG_1 or WG_3) and not SLP_2
EN_2* = en_mRNA_2
hh_mRNA_2* = EN_2 and not CIR_2
HH_2* = hh_mRNA_2
ptc_mRNA_2* = CIA_2 and not EN_2 and not CIR_2
PTC_2* = ptc_mRNA_2 or (PTC_2 and not HH_1 and not HH_3)
PH_2* = (ptc_mRNA_2 or (PTC_2 and not HH_1 and not HH_3)) and (hh_mRNA_1 or hh_mRNA_3)
SMO_2* = not (ptc_mRNA_2 or (PTC_2 and not HH_1 and not HH_3)) or hh_mRNA_1 or hh_mRNA_3
ci_mRNA_2* = not EN_2
CI_2* = ci_mRNA_2
CIA_2* = CI_2 and (SMO_2 or hh_mRNA_1 or hh_mRNA_3)
CIR_2* = CI_2 and not SMO_2 and not hh_mRNA_1 and not hh_mRNA_3
SLP_3* = SLP_3
wg_mRNA_3* = (CIA_3 and SLP_3 and not CIR_3) or (wg_mRNA_3 and (CIA_3 or SLP_3) and not CIR_3)
WG_3* = wg_mRNA_3
en_mRNA_3* = (WG_2 or WG_4) and not SLP_3
EN_3* = en_mRNA_3
hh_mRNA_3* = EN_3 and not CIR_3
HH_3* = hh_mRNA_3
ptc_mRNA_3* = CIA_3 and not EN_3 and not CIR_3
PTC_3* = ptc_mRNA_3 or (PTC_3 and not HH_2 and not HH_4)
PH_3* = (ptc_mRNA_3 or (PTC_3 and not HH_2 and not HH_4)) and (hh_mRNA_2 or hh_mRNA_4)
SMO_3* = not (ptc_mRNA_3 or (PTC_3 and not HH_2 and not HH_4)) or hh_mRNA_2 or hh_mRNA_4
ci_mRNA_3* = not EN_3
CI_3* = ci_mRNA_3
CIA_3* = CI_3 and (SMO_3 or hh_mRNA_2 or hh_mRNA_4)
CIR_3* = CI_3 and not SMO_3 and not hh_mRNA_2 and not hh_mRNA_4
SLP_4* = SLP_4
wg_mRNA_4* = (CIA_4 and SLP_4 and not CIR_4) or (wg_mRNA_4 and (CIA_4 or SLP_4) and not CIR_4)
WG_4* = wg_mRNA_4
en_mRNA_4* = (WG_3 or WG_1) and not SLP_4
EN_4* = en_mRNA_4
hh_mRNA_4* = EN_4 and not CIR_4
HH_4* = hh_mRNA_4
ptc_mRNA_4* = CIA_4 and not EN_4 and not CIR_4
PTC_4* = ptc_mRNA_4 or (PTC_4 and not HH_3 and not HH_1)
PH_4* = (ptc_mRNA_4 or (PTC_4 and not HH_3 and not HH_1)) and (hh_mRNA_3 or hh_mRNA_1)
SMO_4* = not (ptc_mRNA_4 or (PTC_4 and not HH_3 and not HH_1)) or hh_mRNA_3 or hh_mRNA_1
ci_mRNA_4* = not EN_4
CI_4* = ci_mRNA_4
CIA_4* = CI_4 and (SMO_4 or hh_mRNA_3 or hh_mRNA_1)
CIR_4* = CI_4 and not SMO_4 and not hh_mRNA_3 and not hh_mRNA_1
"""
model = Model(rules, mode='sync')
model.initialize()
model.iterate(steps=30)
#------------------------------------------------------- for node in model.data:
#---------------------------------------------- print node, model.data[node]
#cycle = model.report_cycles()
nodeList = []
cell_1_states = []
cell_2_states = []
cell_3_states = []
cell_4_states = []
stateList = str(model.states[model.detect_cycles()[0]])
stateList = stateList.split(' ', 1)[1]
stateList = stateList.split(', ')
for i,state in enumerate(stateList):
if i % 4 == 0:
nodeList.append(state.rsplit('_', 1)[0])
cell_1_states.append(state.rsplit('=', 1)[1])
if i % 4 == 1:
cell_2_states.append(state.rsplit('=', 1)[1])
if i % 4 == 2:
cell_3_states.append(state.rsplit('=', 1)[1])
if i % 4 == 3:
cell_4_states.append(state.rsplit('=', 1)[1])
column_labels = list('1234')
row_labels = nodeList
string = ''
for node in cell_1_states:
if node == 'True':
string = string + '1'
elif node =='False':
string = string + '0'
string = string + ' '
string = string[:-1]
string = string + '; '
for node in cell_2_states:
if node == 'True':
string = string + '1'
elif node =='False':
string = string + '0'
string = string + ' '
string = string[:-1]
string = string + '; '
for node in cell_3_states:
if node == 'True':
string = string + '1'
elif node =='False':
string = string + '0'
string = string + ' '
string = string[:-1]
string = string + '; '
for node in cell_4_states:
if node == 'True':
string = string + '1'
elif node =='False':
string = string + '0'
string = string + ' '
string = string[:-1]
data = np.matrix(string).T
data = np.array(data)
fig, ax = plt.subplots()
heatmap = ax.pcolor(data, cmap=plt.cm.Blues, edgecolors='black', linewidths=.2)
ax.set_xticks(np.arange(data.shape[1]) + 0.5, minor = False)
ax.set_yticks(np.arange(data.shape[0]) + 0.5, minor = False)
plt.ylim(0,len(row_labels))
ax.invert_yaxis()
ax.xaxis.tick_top()
ax.set_xticklabels(column_labels, minor=False)
ax.set_yticklabels(row_labels, minor=False)
plt.show()