-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReactionNetworkExamples.py
More file actions
769 lines (698 loc) · 34.5 KB
/
ReactionNetworkExamples.py
File metadata and controls
769 lines (698 loc) · 34.5 KB
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
import numpy as np
import ReactionNetworkClass as rxn
import scipy.optimize
from scipy import linalg
import sympy as sym
class birth_death_network(rxn.ReactionNetworkDefinition):
"""birth death network"""
def __init__(self):
num_species = 1
num_reactions = 2
species_labels = ["protein"]
output_species_labels = ["protein"]
reactant_matrix = np.zeros([num_reactions, num_species], dtype=int)
product_matrix = np.zeros([num_reactions, num_species], dtype=int)
reactant_matrix[1, 0] = 1 # X --> 0
product_matrix[0, 0] = 1 # 0 --> X
parameter_dict = {'birth rate': 10.0, 'degradation rate': 1.0}
time_unit = "sec."
reaction_dict = {0: ['mass action', 'birth rate'],
1: ['mass action', 'degradation rate']
}
super(birth_death_network, self).__init__(num_species, num_reactions, reactant_matrix,
product_matrix, parameter_dict, reaction_dict,
species_labels, output_species_labels, time_unit)
self.initial_state = np.zeros(self.num_species)
self.set_propensity_vector()
def PSD_analytical(self, omega):
k = self.parameter_dict['birth rate']
gamma = self.parameter_dict['degradation rate']
psd = 2 * k / (omega ** 2 + gamma ** 2)
return psd
class self_regulatory_network(rxn.ReactionNetworkDefinition):
"""birth death network"""
def __init__(self):
num_species = 1
num_reactions = 2
species_labels = ["protein"]
output_species_labels = ["protein"]
reactant_matrix = np.zeros([num_reactions, num_species], dtype=int)
product_matrix = np.zeros([num_reactions, num_species], dtype=int)
reactant_matrix[1, 0] = 1 # X --> 0
product_matrix[0, 0] = 1 # 0 --> X
parameter_dict = {'birth rate': 10.0, 'degradation rate': 0.05, 'Hill coefficient': 0.5, 'Hill constant': 10.0,
'basal rate': 0}
time_unit = "sec."
reaction_dict = { # 0: ['mass action', 'birth rate'],
0: ['Hill_repression', 0, 'birth rate', 'Hill constant', 'Hill coefficient', 'basal rate'],
1: ['mass action', 'degradation rate']
}
super(self_regulatory_network, self).__init__(num_species, num_reactions, reactant_matrix,
product_matrix, parameter_dict, reaction_dict,
species_labels, output_species_labels, time_unit)
self.initial_state = np.zeros(self.num_species)
self.set_propensity_vector()
class cons_gene_expression_network(rxn.ReactionNetworkDefinition):
"""constitutive gene-expression network"""
def __init__(self):
num_species = 2
num_reactions = 4
species_labels = ["mRNA", "protein"]
output_species_labels = ["protein"]
reactant_matrix = np.zeros([num_reactions, num_species], dtype=int)
product_matrix = np.zeros([num_reactions, num_species], dtype=int)
# 1. 0 --> M
product_matrix[0, 0] = 1
# 2. M --> M + P
reactant_matrix[1, 0] = 1
product_matrix[1, 0] = 1
product_matrix[1, 1] = 1
# 3. M --> 0
reactant_matrix[2, 0] = 1
# 4. P -->0
reactant_matrix[3, 1] = 1
# define parameters
parameter_dict = {'transcription rate': 10, 'translation rate': 2, 'mRNA degradation rate': 1,
'protein degradation rate': 0.5}
time_unit = "min."
reaction_dict = {0: ['mass action', 'transcription rate'],
1: ['mass action', 'translation rate'],
2: ['mass action', 'mRNA degradation rate'],
3: ['mass action', 'protein degradation rate']
}
super(cons_gene_expression_network, self).__init__(num_species, num_reactions, reactant_matrix,
product_matrix, parameter_dict, reaction_dict,
species_labels, output_species_labels, time_unit)
self.initial_state = np.zeros(self.num_species)
self.set_propensity_vector()
def PSD_analytical(self, omega):
k_r = self.parameter_dict['transcription rate']
k_p = self.parameter_dict['translation rate']
gamma_r = self.parameter_dict['mRNA degradation rate']
gamma_p = self.parameter_dict['protein degradation rate']
psd = 2 * k_r * k_p / (gamma_r * (gamma_p ** 2 + omega ** 2)) + 2 * k_r * (k_p ** 2) / (
(gamma_r ** 2 + omega ** 2)
* (gamma_p ** 2 + omega ** 2))
return psd
class cons_gene_expression_cell_cycle_network(rxn.ReactionNetworkDefinition):
"""constitutive gene-expression network with cell cycle"""
def __init__(self):
num_species = 4
num_reactions = 5
species_labels = ["mRNA", "protein", "cell cycle counter", "transition_indicator"]
output_species_labels = ["protein"]
reactant_matrix = np.zeros([num_reactions, num_species], dtype=int)
product_matrix = np.zeros([num_reactions, num_species], dtype=int)
# 1. 0 --> M
product_matrix[0, 0] = 1
# 2. M --> M + P
reactant_matrix[1, 0] = 1
product_matrix[1, 0] = 1
product_matrix[1, 1] = 1
# 3. M --> 0
reactant_matrix[2, 0] = 1
# 4. P -->0
reactant_matrix[3, 1] = 1
# 5 0 --> cell cycle counter
product_matrix[4, 2] = 1
# define parameters
parameter_dict = {'transcription rate': 10, 'translation rate': 2, 'mRNA degradation rate': 1,
'protein degradation rate': 0.5, 'cell cycle progression rate': 2.5,
'cell_cycle_length': 10}
time_unit = "min."
reaction_dict = {0: ['mass action', 'transcription rate'],
1: ['mass action', 'translation rate'],
2: ['mass action', 'mRNA degradation rate'],
3: ['mass action', 'protein degradation rate'],
4: ['mass action', 'cell cycle progression rate']
}
super(cons_gene_expression_cell_cycle_network, self).__init__(num_species, num_reactions, reactant_matrix,
product_matrix, parameter_dict, reaction_dict,
species_labels, output_species_labels, time_unit)
self.initial_state = np.zeros(self.num_species)
self.set_propensity_vector()
# def update_state(self, next_reaction, state):
# if next_reaction != -1:
# state = state + self.stoichiometry_matrix[next_reaction, :]
# if next_reaction == 4:
# state[2] = state[2] % self.parameter_dict['cell_cycle_length']
# if state[2] == (self.parameter_dict['cell_cycle_length'] - 1):
# state[3] = 1
# if state[2] == 0:
# state[3] = 0
# state[0] = state[0] // 2 # partitioning in half
# state[1] = state[1] // 2
# return state
# symmetric binomial partition
def update_state(self, next_reaction, state):
prob = 0.5
if next_reaction != -1:
state = state + self.stoichiometry_matrix[next_reaction, :]
if next_reaction == 4:
state[2] = state[2] % self.parameter_dict['cell_cycle_length']
if state[2] == (self.parameter_dict['cell_cycle_length'] - 1):
state[3] = 1
if state[2] == 0:
state[3] = 0
state[0] = np.random.binomial(state[0], prob)
state[1] = np.random.binomial(state[1], prob)
return state
class feedback_gene_expression_network(rxn.ReactionNetworkDefinition):
"""nonlinear feedback gene-expression network"""
def __init__(self):
num_species = 2
num_reactions = 4
species_labels = ["mRNA", "protein"]
output_species_labels = ["protein"]
reactant_matrix = np.zeros([num_reactions, num_species], dtype=int)
product_matrix = np.zeros([num_reactions, num_species], dtype=int)
# 1. 0 --> M
product_matrix[0, 0] = 1
# 2. M --> M + P
reactant_matrix[1, 0] = 1
product_matrix[1, 0] = 1
product_matrix[1, 1] = 1
# 3. M --> 0
reactant_matrix[2, 0] = 1
# 4. P -->0
reactant_matrix[3, 1] = 1
# define parameters
parameter_dict = {'base transcription rate': 10.0, 'Hill constant': 10.0, 'Hill coefficient': 1.0,
'basal rate': 135.81644, # theta * 67.90822
'translation rate': 1.0,
'mRNA degradation rate': 1.0, 'protein degradation rate': 1.0}
time_unit = "sec."
reaction_dict = {0: ['Hill_repression', 1, 'base transcription rate', 'Hill constant', 'Hill coefficient',
'basal rate'],
1: ['mass action', 'translation rate'],
2: ['mass action', 'mRNA degradation rate'],
3: ['mass action', 'protein degradation rate']
}
super(feedback_gene_expression_network, self).__init__(num_species, num_reactions, reactant_matrix,
product_matrix, parameter_dict, reaction_dict,
species_labels, output_species_labels, time_unit)
self.initial_state = np.zeros(self.num_species)
self.set_propensity_vector()
class negative_feedback_network(rxn.ReactionNetworkDefinition):
"""negative feedback network with linearisation"""
def __init__(self):
num_species = 2
num_reactions = 4
species_labels = ["controller", "output"]
output_species_labels = ["output"]
reactant_matrix = np.zeros([num_reactions, num_species], dtype=int)
product_matrix = np.zeros([num_reactions, num_species], dtype=int)
# 1. I_0 --> I_0 + C
product_matrix[0, 0] = 1
# 2. C --> C + O
reactant_matrix[1, 0] = 1
product_matrix[1, 0] = 1
product_matrix[1, 1] = 1
# 3. C --> 0
reactant_matrix[2, 0] = 1
# 4. O -->0
reactant_matrix[3, 1] = 1
# define parameters
parameter_dict = {'constant term': 50.0, 'slope': -0.5,
'production rate': 2.0,
'controller degradation rate': 1.0, 'output degradation rate': 0.5}
time_unit = "sec."
reaction_dict = {0: ['linear', 1, 'constant term', 'slope'],
1: ['mass action', 'production rate'],
2: ['mass action', 'controller degradation rate'],
3: ['mass action', 'output degradation rate']
}
super(negative_feedback_network, self).__init__(num_species, num_reactions, reactant_matrix,
product_matrix, parameter_dict, reaction_dict,
species_labels, output_species_labels, time_unit)
self.initial_state = np.zeros(self.num_species)
self.set_propensity_vector()
def PSD_analytical(self, omega):
beta_0 = self.parameter_dict['constant term']
beta_fb = -self.parameter_dict['slope']
k_o = self.parameter_dict['production rate']
gamma_c = self.parameter_dict['controller degradation rate']
gamma_o = self.parameter_dict['output degradation rate']
num = 2 * gamma_o * k_o * beta_0 * (gamma_c ** 2 + k_o * gamma_c + omega ** 2)
den = ((gamma_c * gamma_o + beta_fb * k_o) ** 2 + (omega ** 2) * (
gamma_c ** 2 + gamma_o ** 2 - 2 * k_o * beta_fb) +
omega ** 4) * (gamma_c * gamma_o + beta_fb * k_o)
psd = num / den
return psd
class negative_feedforward_network(rxn.ReactionNetworkDefinition):
"""negative feedforward network with linearisation"""
def __init__(self):
num_species = 2
num_reactions = 4
species_labels = ["controller", "output"]
output_species_labels = ["output"]
reactant_matrix = np.zeros([num_reactions, num_species], dtype=int)
product_matrix = np.zeros([num_reactions, num_species], dtype=int)
# 1. I_0 --> I_0 + C
product_matrix[0, 0] = 1
# 2. I_0 --> I_0 + O
product_matrix[1, 1] = 1
# 3. C --> 0
reactant_matrix[2, 0] = 1
# 4. O -->0
reactant_matrix[3, 1] = 1
# define parameters
parameter_dict = {'constant term': 50.0, 'slope': -3.0,
'controller production rate': 1.0,
'controller degradation rate': 1.0, 'output degradation rate': 0.5}
time_unit = "sec."
reaction_dict = {0: ['mass action', 'controller production rate'],
1: ['linear', 0, 'constant term', 'slope'],
2: ['mass action', 'controller degradation rate'],
3: ['mass action', 'output degradation rate']
}
super(negative_feedforward_network, self).__init__(num_species, num_reactions, reactant_matrix,
product_matrix, parameter_dict, reaction_dict,
species_labels, output_species_labels, time_unit)
self.initial_state = np.zeros(self.num_species)
self.set_propensity_vector()
def PSD_analytical(self, omega):
beta_0 = self.parameter_dict['constant term']
beta_ff = -self.parameter_dict['slope']
k_c = self.parameter_dict['controller production rate']
gamma_c = self.parameter_dict['controller degradation rate']
gamma_o = self.parameter_dict['output degradation rate']
psd = (2 / (gamma_o ** 2 + omega ** 2)) * (
beta_0 - beta_ff * k_c / gamma_c + (beta_ff ** 2) * k_c / (gamma_c ** 2
+ omega ** 2))
return psd
class rna_splicing_network(rxn.ReactionNetworkDefinition):
"""linear rna splicing network"""
def __init__(self):
num_species = 4
num_reactions = 6
species_labels = ["gene off", "gene on", "unspliced mrna", "spliced mrna"]
output_species_labels = ["spliced mrna"]
reactant_matrix = np.zeros([num_reactions, num_species], dtype=int)
product_matrix = np.zeros([num_reactions, num_species], dtype=int)
# 1. gene switching on
reactant_matrix[0, 0] = 1
product_matrix[0, 1] = 1
# 2. gene switching off
reactant_matrix[1, 1] = 1
product_matrix[1, 0] = 1
# 3. transcription reaction
product_matrix[2, 2] = 1
# 4. splicing reaction
reactant_matrix[3, 2] = 1
product_matrix[3, 3] = 1
# 4. degradation reaction for spliced mrna
reactant_matrix[4, 3] = 1
# 5. degradation reaction for the unspliced mrna
reactant_matrix[5, 2] = 1
# define parameters
parameter_dict = {'k_on': 1.0, 'k_off': 3.0, 'alpha_on': 3.0, 'alpha_off': 0.2,
'beta': 2.0, 'gamma_r': 0.5, 'gamma_u': 1.0}
slope = parameter_dict['alpha_on'] - parameter_dict['alpha_off']
parameter_dict["slope"] = slope
time_unit = "sec."
reaction_dict = {0: ['mass action', 'k_on'], # gene switching on
1: ['mass action', 'k_off'], # gene switching off
2: ['linear', 1, 'alpha_off', 'slope'], # transcription reaction
3: ['mass action', 'beta'], # splicing reaction
4: ['mass action', 'gamma_r'], # degradation reaction for spliced mRNA
5: ['mass action', 'gamma_u'] # degradation reaction for unspliced mRNA
}
super(rna_splicing_network, self).__init__(num_species, num_reactions, reactant_matrix,
product_matrix, parameter_dict, reaction_dict,
species_labels, output_species_labels, time_unit)
self.initial_state = np.zeros(self.num_species)
self.initial_state[0] = 1
self.set_propensity_vector()
def PSD_analytical(self, omega):
gamma_r = self.parameter_dict['gamma_r']
gamma_u = self.parameter_dict['gamma_u']
beta = self.parameter_dict['beta']
k_on = self.parameter_dict['k_on']
k_off = self.parameter_dict['k_off']
alpha_on = self.parameter_dict['alpha_on']
alpha_off = self.parameter_dict['alpha_off']
# omega = sym.Symbol('omega')
psd_gene_switch = 2 * k_on * k_off / ((k_on + k_off) * ((k_on + k_off) ** 2 + omega ** 2))
mean_transcription_rate = (alpha_off * k_off + alpha_on * k_on) / (k_on + k_off)
factor = ((alpha_on - alpha_off) ** 2) * (beta ** 2) / (
((beta + gamma_u) ** 2 + omega ** 2) * (gamma_r ** 2 + omega ** 2))
psd = 2 * beta * mean_transcription_rate / (
(gamma_r ** 2 + omega ** 2) * (beta + gamma_u)) + psd_gene_switch * factor
return psd
class antithetic_gene_expression_network(rxn.ReactionNetworkDefinition):
"""antithetic gene-expression network"""
def __init__(self):
name = "antithetic gene expression"
num_species = 4
num_reactions = 7
species_labels = ["mRNA", "protein", "Z1", "Z2"]
output_species_labels = ["protein"]
reactant_matrix = np.zeros([num_reactions, num_species], dtype=int)
product_matrix = np.zeros([num_reactions, num_species], dtype=int)
# 1. Z_1 --> Z_1 + M
product_matrix[0, 2] = 1
product_matrix[0, 0] = 1
reactant_matrix[0, 2] = 1
# 2. M --> M + P
reactant_matrix[1, 0] = 1
product_matrix[1, 0] = 1
product_matrix[1, 1] = 1
# 3. M --> 0
reactant_matrix[2, 0] = 1
# 4. P -->0
reactant_matrix[3, 1] = 1
# 5. P -->P + Z_2
reactant_matrix[4, 1] = 1
product_matrix[4, 1] = 1
product_matrix[4, 3] = 1
# 6. Z_1 + Z_2 -->0
reactant_matrix[5, 2] = 1
reactant_matrix[5, 3] = 1
# 7. 0 --> Z_1
product_matrix[6, 2] = 1
# define parameters
parameter_dict = {'activation rate': 5.0,
'translation rate': 2.0,
'mRNA degradation rate': 2.0,
'protein degradation rate': 1.0,
'theta': 1,
'eta': 100,
'mu': 10,
'k_fb': 5,
'feedback_type': 'Hill' # could be Hill or linear
}
time_unit = "sec."
reaction_dict = {0: ['mass action', 'activation rate'],
1: ['mass action', 'translation rate'],
2: ['mass action', 'mRNA degradation rate'],
3: ['mass action', 'protein degradation rate'],
4: ['mass action', 'theta'],
5: ['mass action', 'eta'],
6: ['mass action', 'mu']
}
super(antithetic_gene_expression_network, self).__init__(num_species, num_reactions, reactant_matrix,
product_matrix, parameter_dict, reaction_dict,
species_labels, output_species_labels, time_unit)
self.initial_state = np.zeros(self.num_species)
def propensity_vector(self, state):
prop = np.zeros(self.num_reactions)
for k in range(1, self.num_reactions):
prop[k] = self.mass_action_propensity(state, k, self.reaction_dict[k][1])
prop[0] = self.mass_action_propensity(state, 0, self.reaction_dict[0][1])
reference = self.parameter_dict['mu'] / self.parameter_dict['theta']
output = state[1]
k_fb = self.parameter_dict['k_fb']
if k_fb > 0 and self.parameter_dict['feedback_type'] == 'Hill':
prop[0] += 4 * k_fb * (reference ** 2) / (reference + output)
elif k_fb > 0 and self.parameter_dict['feedback_type'] == 'linear':
prop[0] += k_fb * max(3 * reference - output, 0)
return prop
def function_err(x, N_pro, p_tot, K, hill_coeff):
return p_tot - x - 2 * N_pro * (x ** hill_coeff) / (x ** hill_coeff + K ** hill_coeff)
def ComputeFreeProteins(N_pro, p_tot, K, hill_coeff):
return scipy.optimize.bisect(function_err, 0, p_tot, args=(N_pro, p_tot, K, hill_coeff,), xtol=2e-3, maxiter=100,
full_output=False, disp=True)
class repressilator_network(rxn.ReactionNetworkDefinition):
"""repressilator network"""
def __init__(self):
name = "repressilator network"
num_species = 5
num_reactions = 10
species_labels = ["p_tot_1", "p_tot_2", "p_tot_3", "N_o", "N_t"]
output_species_labels = ["p_tot_2"]
reactant_matrix = np.zeros([num_reactions, num_species], dtype=int)
product_matrix = np.zeros([num_reactions, num_species], dtype=int)
# 1. 0 --> P_tot1
product_matrix[0, 0] = 1
# 2. 0 --> P_tot2
product_matrix[1, 1] = 1
# 3. 0 --> P_tot3
product_matrix[2, 2] = 1
# 4. P_tot1 -->0
reactant_matrix[3, 0] = 1
# 5. P_tot2 -->0
reactant_matrix[4, 1] = 1
# 6. P_tot3 -->0
reactant_matrix[5, 2] = 1
# 7. 0 --> N_0
product_matrix[6, 3] = 1
# 8. 0 --> N_t
product_matrix[7, 4] = 1
# 9. N_0 --> 0
reactant_matrix[8, 3] = 1
# 10. N_t --> 0
reactant_matrix[9, 4] = 1
# define parameters
parameter_dict = {'lambda': 30,
'K1': 5,
'K2': 10,
'K3': 10,
'Mean_No': 10,
'Mean_Nt': 0, # 40, 0
'Hill factor': 2, # 1.5/2
'dilution rate': 1
}
time_unit = "min."
reaction_dict = {3: ['mass action', 'dilution rate'],
4: ['mass action', 'dilution rate'],
5: ['mass action', 'dilution rate'],
6: ['mass action', 'Mean_No'],
7: ['mass action', 'Mean_Nt'],
8: ['mass action', 'dilution rate'],
9: ['mass action', 'dilution rate'],
}
super(repressilator_network, self).__init__(num_species, num_reactions, reactant_matrix,
product_matrix, parameter_dict, reaction_dict,
species_labels, output_species_labels, time_unit)
self.initial_state = np.zeros(self.num_species)
def propensity_vector(self, state):
prop = np.zeros(self.num_reactions)
for k in range(3, self.num_reactions):
prop[k] = self.mass_action_propensity(state, k, self.reaction_dict[k][1])
p_tot_1 = state[0]
p_tot_2 = state[1]
p_tot_3 = state[2]
p_free_1 = ComputeFreeProteins(state[3] + state[4], p_tot_1, self.parameter_dict['K1'],
self.parameter_dict['Hill factor'])
p_free_2 = ComputeFreeProteins(state[3], p_tot_2, self.parameter_dict['K2'],
self.parameter_dict['Hill factor'])
p_free_3 = ComputeFreeProteins(state[3], p_tot_3, self.parameter_dict['K3'],
self.parameter_dict['Hill factor'])
H = self.parameter_dict['Hill factor']
K1 = self.parameter_dict['K1']
K2 = self.parameter_dict['K2']
K3 = self.parameter_dict['K3']
prop[0] = self.parameter_dict['lambda'] * self.parameter_dict['Mean_No'] * (
(K1 ** H) / (K1 ** H + p_free_3 ** H))
prop[1] = self.parameter_dict['lambda'] * self.parameter_dict['Mean_No'] * (
(K2 ** H) / (K2 ** H + p_free_1 ** H))
prop[2] = self.parameter_dict['lambda'] * self.parameter_dict['Mean_No'] * (
(K3 ** H) / (K3 ** H + p_free_2 ** H))
return prop
class repressilator_network_with_gene_expression(rxn.ReactionNetworkDefinition):
"""repressilator network with gene expression"""
def __init__(self):
name = "repressilator network"
num_species = 7
num_reactions = 14
species_labels = ["p_tot_1", "p_tot_2", "p_tot_3", "N_o", "N_t", "mRNA", "protein"]
output_species_labels = ["protein"]
reactant_matrix = np.zeros([num_reactions, num_species], dtype=int)
product_matrix = np.zeros([num_reactions, num_species], dtype=int)
# 1. 0 --> P_tot1
product_matrix[0, 0] = 1
# 2. 0 --> P_tot2
product_matrix[1, 1] = 1
# 3. 0 --> P_tot3
product_matrix[2, 2] = 1
# 4. P_tot1 -->0
reactant_matrix[3, 0] = 1
# 5. P_tot2 -->0
reactant_matrix[4, 1] = 1
# 6. P_tot3 -->0
reactant_matrix[5, 2] = 1
# 7. 0 --> N_0
product_matrix[6, 3] = 1
# 8. 0 --> N_t
product_matrix[7, 4] = 1
# 9. N_0 --> 0
reactant_matrix[8, 3] = 1
# 10. N_t --> 0
reactant_matrix[9, 4] = 1
# 11. 0 --> mRNA
product_matrix[10, 5] = 1
# 12. mRNA --> mRNA + protein
reactant_matrix[11, 5] = 1
product_matrix[11, 5] = 1
product_matrix[11, 6] = 1
# 13. mRNA --> 0
reactant_matrix[12, 5] = 1
# 13. protein --> 0
reactant_matrix[13, 6] = 1
# define parameters
parameter_dict = {'lambda': 30,
'K1': 5,
'K2': 10,
'K3': 10,
'Mean_No': 10,
'Mean_Nt': 0,
'Hill factor': 1.5,
'dilution rate': 1,
'theta': 0.4,
'k_r': 50,
'k_p': 2,
'k_fb': 0.5,
'gamma_r': 1,
'gamma_p': 0.5
}
time_unit = "min."
reaction_dict = {3: ['mass action', 'dilution rate'],
4: ['mass action', 'dilution rate'],
5: ['mass action', 'dilution rate'],
6: ['mass action', 'Mean_No'],
7: ['mass action', 'Mean_Nt'],
8: ['mass action', 'dilution rate'],
9: ['mass action', 'dilution rate'],
11: ['mass action', 'k_p'],
12: ['mass action', 'gamma_r'],
13: ['mass action', 'gamma_p'],
}
super(repressilator_network_with_gene_expression, self).__init__(num_species, num_reactions, reactant_matrix,
product_matrix, parameter_dict, reaction_dict,
species_labels, output_species_labels,
time_unit)
self.initial_state = np.zeros(self.num_species)
def propensity_vector(self, state):
prop = np.zeros(self.num_reactions)
for k in range(3, 10):
prop[k] = self.mass_action_propensity(state, k, self.reaction_dict[k][1])
for k in range(11, 14):
prop[k] = self.mass_action_propensity(state, k, self.reaction_dict[k][1])
p_tot_1 = state[0]
p_tot_2 = state[1]
p_tot_3 = state[2]
prop[10] = max(self.parameter_dict['theta'] * p_tot_2 + self.parameter_dict['k_r'] -
self.parameter_dict['k_fb'] * state[6], 0)
p_free_1 = ComputeFreeProteins(state[3] + state[4], p_tot_1, self.parameter_dict['K1'],
self.parameter_dict['Hill factor'])
p_free_2 = ComputeFreeProteins(state[3], p_tot_2, self.parameter_dict['K2'],
self.parameter_dict['Hill factor'])
p_free_3 = ComputeFreeProteins(state[3], p_tot_3, self.parameter_dict['K3'],
self.parameter_dict['Hill factor'])
H = self.parameter_dict['Hill factor']
K1 = self.parameter_dict['K1']
K2 = self.parameter_dict['K2']
K3 = self.parameter_dict['K3']
prop[0] = self.parameter_dict['lambda'] * self.parameter_dict['Mean_No'] * (
(K1 ** H) / (K1 ** H + p_free_3 ** H))
prop[1] = self.parameter_dict['lambda'] * self.parameter_dict['Mean_No'] * (
(K2 ** H) / (K2 ** H + p_free_1 ** H))
prop[2] = self.parameter_dict['lambda'] * self.parameter_dict['Mean_No'] * (
(K3 ** H) / (K3 ** H + p_free_2 ** H))
return prop
class repressilator_network_with_nonlinear_gene_expression(rxn.ReactionNetworkDefinition):
"""repressilator network with nonlinear gene expression"""
def __init__(self):
name = "repressilator nonlinear ge network"
num_species = 7
num_reactions = 14
species_labels = ["p_tot_1", "p_tot_2", "p_tot_3", "N_o", "N_t", "mRNA", "protein"]
output_species_labels = ["protein"]
reactant_matrix = np.zeros([num_reactions, num_species], dtype=int)
product_matrix = np.zeros([num_reactions, num_species], dtype=int)
# 1. 0 --> P_tot1
product_matrix[0, 0] = 1
# 2. 0 --> P_tot2
product_matrix[1, 1] = 1
# 3. 0 --> P_tot3
product_matrix[2, 2] = 1
# 4. P_tot1 -->0
reactant_matrix[3, 0] = 1
# 5. P_tot2 -->0
reactant_matrix[4, 1] = 1
# 6. P_tot3 -->0
reactant_matrix[5, 2] = 1
# 7. 0 --> N_0
product_matrix[6, 3] = 1
# 8. 0 --> N_t
product_matrix[7, 4] = 1
# 9. N_0 --> 0
reactant_matrix[8, 3] = 1
# 10. N_t --> 0
reactant_matrix[9, 4] = 1
# 11. 0 --> mRNA
product_matrix[10, 5] = 1
# 12. mRNA --> mRNA + protein
reactant_matrix[11, 5] = 1
product_matrix[11, 5] = 1
product_matrix[11, 6] = 1
# 13. mRNA --> 0
reactant_matrix[12, 5] = 1
# 13. protein --> 0
reactant_matrix[13, 6] = 1
# define parameters
parameter_dict = {'lambda': 30,
'K1': 5,
'K2': 10,
'K3': 10,
'Mean_No': 10,
'Mean_Nt': 0,
'Hill factor': 1.5,
'dilution rate': 1,
'theta': 0.4,
'base transcription rate': 10.0,
'Hill constant': 10.0,
'Hill coefficient': 1.0,
'k_p': 2,
'gamma_r': 1,
'gamma_p': 0.5
}
time_unit = "min."
reaction_dict = {3: ['mass action', 'dilution rate'],
4: ['mass action', 'dilution rate'],
5: ['mass action', 'dilution rate'],
6: ['mass action', 'Mean_No'],
7: ['mass action', 'Mean_Nt'],
8: ['mass action', 'dilution rate'],
9: ['mass action', 'dilution rate'],
11: ['mass action', 'k_p'],
12: ['mass action', 'gamma_r'],
13: ['mass action', 'gamma_p'],
}
super(repressilator_network_with_nonlinear_gene_expression, self).__init__(num_species, num_reactions,
reactant_matrix,
product_matrix, parameter_dict,
reaction_dict,
species_labels,
output_species_labels,
time_unit)
self.initial_state = np.zeros(self.num_species)
def propensity_vector(self, state):
prop = np.zeros(self.num_reactions)
for k in range(3, 10):
prop[k] = self.mass_action_propensity(state, k, self.reaction_dict[k][1])
for k in range(11, 14):
prop[k] = self.mass_action_propensity(state, k, self.reaction_dict[k][1])
p_tot_1 = state[0]
p_tot_2 = state[1]
p_tot_3 = state[2]
prop[10] = self.parameter_dict['theta'] * p_tot_2 + self.parameter_dict['base transcription rate'] / (
self.parameter_dict['Hill constant'] + (state[6] ** self.parameter_dict['Hill coefficient']))
p_free_1 = ComputeFreeProteins(state[3] + state[4], p_tot_1, self.parameter_dict['K1'],
self.parameter_dict['Hill factor'])
p_free_2 = ComputeFreeProteins(state[3], p_tot_2, self.parameter_dict['K2'],
self.parameter_dict['Hill factor'])
p_free_3 = ComputeFreeProteins(state[3], p_tot_3, self.parameter_dict['K3'],
self.parameter_dict['Hill factor'])
H = self.parameter_dict['Hill factor']
K1 = self.parameter_dict['K1']
K2 = self.parameter_dict['K2']
K3 = self.parameter_dict['K3']
prop[0] = self.parameter_dict['lambda'] * self.parameter_dict['Mean_No'] * (
(K1 ** H) / (K1 ** H + p_free_3 ** H))
prop[1] = self.parameter_dict['lambda'] * self.parameter_dict['Mean_No'] * (
(K2 ** H) / (K2 ** H + p_free_1 ** H))
prop[2] = self.parameter_dict['lambda'] * self.parameter_dict['Mean_No'] * (
(K3 ** H) / (K3 ** H + p_free_2 ** H))
return prop