-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathTutorial_1b.py
More file actions
63 lines (53 loc) · 2.21 KB
/
Copy pathTutorial_1b.py
File metadata and controls
63 lines (53 loc) · 2.21 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
import random
from CellModeller.Regulation.ModuleRegulator import ModuleRegulator
from CellModeller.Biophysics.BacterialModels.CLBacterium import CLBacterium
from CellModeller.GUI import Renderers
import numpy
import math
cell_cols = {0:[0,1.0,0], 1:[1.0,0,0], 2:[0,0,1.0]} #RGB cell colours
cell_lens = {0:1.0, 1:2.0, 2:3.5} #target cell lengths
cell_growr = {0:2.0, 1:1.1, 2:0.8} #growth rates
def setup(sim):
# Set biophysics, signalling, and regulation models
biophys = CLBacterium(sim, jitter_z=False)
# use this file for reg too
regul = ModuleRegulator(sim, sim.moduleName)
# Only biophys and regulation
sim.init(biophys, regul, None, None)
# Specify the initial cell and its location in the simulation
sim.addCell(cellType=0, pos=(0,0,0), dir=(1,0,0))
sim.addCell(cellType=1, pos=(6,0,0), dir=(1,0,0))
sim.addCell(cellType=2, pos=(-6,0,0), dir=(1,0,0))
# Add some objects to draw the models
therenderer = Renderers.GLBacteriumRenderer(sim)
sim.addRenderer(therenderer)
sim.pickleSteps = 20
def max_y_coord(cells):
#finds the largest y-coordinate in the colony
my = 0.0
for i,cell in list(cells.items()):
my = max(my, cell.pos[1])
return my
def init(cell):
# Specify mean and distribution of initial cell size
cell.targetVol = cell_lens[cell.cellType] + random.uniform(0.0,0.5)
# Specify growth rate of cells
cell.growthRate = cell_growr[cell.cellType]
cell.color = cell_cols[cell.cellType]
def update(cells):
#Iterate through each cell and flag cells that reach target size for division
maxy = max_y_coord(cells)
for (id, cell) in cells.items():
dist = maxy - cell.pos[1]
growthZone = 5.0 #width of the growth zone
if dist < growthZone:
cell.growthRate = cell_growr[cell.cellType]
else:
cell.color = numpy.divide(cell_cols[cell.cellType],2)
cell.growthRate = 0.0
if cell.volume > cell.targetVol:
cell.divideFlag = True
def divide(parent, d1, d2):
# Specify target cell size that triggers cell division
d1.targetVol = cell_lens[parent.cellType] + random.uniform(0.0,0.5)
d2.targetVol = cell_lens[parent.cellType] + random.uniform(0.0,0.5)