|
| 1 | +from mobspy import * |
| 2 | +import seaborn |
| 3 | +import matplotlib.pyplot as plt |
| 4 | +import numpy as np |
| 5 | + |
| 6 | + |
| 7 | +max_plas, max_pbad, max_ptet = (1, 1, 1) |
| 8 | + |
| 9 | +Mortal, Location = BaseSpecies() |
| 10 | +Location.c1, Location.c2, Location.c3, Location.c4 |
| 11 | +PBad, PTet, Pcl, PLas, Movable = New(Location) |
| 12 | +Ara, aTc, Cl, YFP, AHL, OC12 = New(Mortal*Movable) |
| 13 | +n = 50 |
| 14 | +# n = 10 - for testing |
| 15 | +# Parametric sweeps for XOR gate analysis |
| 16 | +ara_entrace_rate, atc_entrace_rate = ModelParameters([float(x) for x in np.linspace(0, 35, n)], |
| 17 | + [float(x) for x in np.linspace(0, 2000, n)]) |
| 18 | + |
| 19 | +# Death and movement reactions |
| 20 | +Mortal >> Zero[1] |
| 21 | +for x, y in zip(['c1', 'c1', 'c2', 'c3'], ['c2', 'c3', 'c4', 'c4']): |
| 22 | + Movable.c(x) >> Movable.c(y) [0.1] |
| 23 | + |
| 24 | +# Represents the entrance of aTc and Ara in the system |
| 25 | +def diffusion_in_cell(Molecule, rate, locations): |
| 26 | + for l in locations: |
| 27 | + Zero >> Molecule.c(l) [rate] |
| 28 | +diffusion_in_cell(Ara, ara_entrace_rate, ['c1', 'c2']) |
| 29 | +diffusion_in_cell(aTc, atc_entrace_rate, ['c1', 'c3']) |
| 30 | + |
| 31 | +# Promoter activation function |
| 32 | +def promoter_activation(P, Ligand, Protein, tf_max, n, |
| 33 | + K_d, protein_production_rate, locations): |
| 34 | + tf_linked = lambda lig: tf_max * lig ** n / (lig ** n + K_d ** n) |
| 35 | + tf_free = lambda lig: tf_max - tf_max * lig ** n / (lig ** n + K_d ** n) |
| 36 | + pr = lambda r1, r2: protein_production_rate(r1, tf_linked(r2), tf_free(r2)) |
| 37 | + for l in locations: |
| 38 | + with Location.c(l): |
| 39 | + P + Ligand >> P + Ligand + Protein [pr] |
| 40 | + |
| 41 | +# Inverter for each nor gate |
| 42 | +def inverter_wire(P, R, Signal, locations): |
| 43 | + rate_f = lambda r1, r2: 181*r1*350/(1 + 350 + 15*r2 + 50*r2 + 15*50*0.18*r2**2) |
| 44 | + for l in locations: |
| 45 | + with Location.c(l): |
| 46 | + P + R >> P + R + Signal[rate_f] |
| 47 | + |
| 48 | +# Custom buffer for clear visibility |
| 49 | +def buffer(L, Signal, l, n, K): |
| 50 | + with Location.c(l): |
| 51 | + L >> L + Signal [lambda r: 30*r**n/(r**n + K**n)] |
| 52 | + |
| 53 | +# Each promoter expression is written here and assign to the promoter function |
| 54 | +pbad_p_rate = lambda r1, r2, r3: 765*r1*(0.009 + 37.5*r2)/(1 + 0.009 + 37.5*r2 + 3.4*r3) |
| 55 | +promoter_activation(PBad, Ara, Cl, max_pbad, 2.8, 90, pbad_p_rate, ['c1', 'c2']) |
| 56 | +ptet_p_rate = lambda r1, r2, r3: 300*r1*350/(1 + 350 + 2*160*r3 + 160**2*r3**2) |
| 57 | +promoter_activation(PTet, aTc, Cl, max_ptet, 1.0, 250, ptet_p_rate, ['c1', 'c3']) |
| 58 | +plas_p_rate = lambda r1, r2, r3: 69*r1*(0.002 + 100*r2)/(1 + 0.002 + 100*r2) |
| 59 | +promoter_activation(PLas, AHL, Cl, max_plas, 1.4, 0.2, plas_p_rate, ['c2', 'c3']) |
| 60 | +# Inverter wires in all the gates |
| 61 | +inverter_wire(Pcl, Cl, AHL, ['c1']), inverter_wire(Pcl, Cl, OC12, ['c2', 'c3']) |
| 62 | +# Buffer for YFP |
| 63 | +buffer(OC12, YFP, 'c4', 4, 0.04) |
| 64 | + |
| 65 | +# Count assignment and Sim |
| 66 | +model = set_counts({Ara: 0, aTc: 0, Cl: 0, YFP: 0, PBad.c1: 1, PBad.c2: 1, PTet.c1: 1, PTet.c3: 1, |
| 67 | + Pcl.c1: 1, Pcl.c2: 1, Pcl.c3: 1, PLas.c2: 1, PLas.c3: 1, AHL: 0, OC12: 0}) |
| 68 | +S = Simulation(model) |
| 69 | +S.duration = 100 |
| 70 | +S.plot_data = False |
| 71 | +S.run() |
| 72 | + |
| 73 | +matrix = [] |
| 74 | +line = [] |
| 75 | +for i, r in enumerate(S.results[YFP]): |
| 76 | + line.append(r[-1]) |
| 77 | + if (i + 1) % n == 0: |
| 78 | + matrix.append(line) |
| 79 | + line = [] |
| 80 | + |
| 81 | +ax = seaborn.heatmap(matrix) |
| 82 | + |
| 83 | +# Invert the y-axis |
| 84 | +ax.invert_yaxis() |
| 85 | + |
| 86 | +plt.title('XOR Gate Heatmap', fontsize=18) |
| 87 | +plt.xlabel('Ara (a.u.)', fontsize=14) |
| 88 | +plt.ylabel('aTc (a.u.)', fontsize=14) |
| 89 | +plt.show() |
0 commit comments