-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMovieS3.py
108 lines (60 loc) · 2.04 KB
/
MovieS3.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
import random
from CellModeller.Regulation.ModuleRegulator import ModuleRegulator
from CellModeller.Biophysics.BacterialModels.CLBacterium import CLBacterium
from CellModeller.GUI import Renderers
from CellModeller.Integration.CLCrankNicIntegrator import CLCrankNicIntegrator #add
import numpy
import math
def setup(sim):
# Set biophysics, signalling, and regulation models
biophys = CLBacterium(sim, jitter_z=False, max_cells=50000)
regul = ModuleRegulator(sim, sim.moduleName) # use this file for reg too
# Only biophys and regulation
sim.init(biophys, regul, None, None)
sim.addCell(cellType=0, pos=(0,0,0))
# Add some objects to draw the models
therenderer = Renderers.GLBacteriumRenderer(sim)
sim.addRenderer(therenderer)
sim.pickleSteps = 10
def init(cell):
cell.targetVol = 3.5 + random.uniform(0.0,0.5)
cell.growthRate = 1.0
cell.n_a = 1
cell.n_b = 1
def init(cell):
cell.targetVol = 3.5 + random.uniform(0.0,0.5)
cell.growthRate = 1.0
cell.n = [1,1,1,1]
def update(cells):
for (id, cell) in cells.iteritems():
r = 0.3+cell.n[0]/3.0
g = 0.3+cell.n[1]/3.0
b = 0.3+cell.n[2]/3.0
y = 0.3+cell.n[3]/3.0
r += y
g += y
cell.color = [r,g,b]
if cell.volume > cell.targetVol:
cell.divideFlag = True
def divide(parent, d1, d2):
d1.targetVol = 3.5 + random.uniform(0.0,0.5)
d2.targetVol = 3.5 + random.uniform(0.0,0.5)
plasmids = []
for i in range(4):
plasmids += [i]*parent.n[i]*2
d1.n[i] = 0
d2.n[i] = 0
random.shuffle(plasmids)
for p in plasmids[:4]:
d1.n[p] += 1
for p in plasmids[4:8]:
d2.n[p] += 1
'''
assert parent.n_a + parent.n_b == 2
assert d1.n_a + d1.n_b == 2
assert d2.n_a + d2.n_b == 2
assert parent.n_a*2 == d1.n_a+d2.n_a
assert parent.n_b*2 == d1.n_b+d2.n_b
assert parent.n_a > 0 or (d1.n_a == 0 and d2.n_a == 0)
assert parent.n_b > 0 or (d1.n_b == 0 and d2.n_b == 0)
'''