-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathTutorial_2a.py
More file actions
66 lines (49 loc) · 1.9 KB
/
Copy pathTutorial_2a.py
File metadata and controls
66 lines (49 loc) · 1.9 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
import random
from CellModeller.Regulation.ModuleRegulator import ModuleRegulator
from CellModeller.Biophysics.BacterialModels.CLBacterium import CLBacterium
from CellModeller.GUI import Renderers
import numpy
import math
#Import Euler integrator for solving ODE system of chemical species inside the cells
from CellModeller.Integration.CLEulerIntegrator import CLEulerIntegrator
max_cells = 100000
def setup(sim):
# Set biophysics, signalling, and regulation models
biophys = CLBacterium(sim, max_cells=max_cells, jitter_z=False)
integ = CLEulerIntegrator(sim, 1, max_cells)
# use this file for reg too
regul = ModuleRegulator(sim)
# Only biophys and regulation
sim.init(biophys, regul, None, integ)
# Specify the initial cell and its location in the simulation
sim.addCell(cellType=0, pos=(0,0,0))
# Add some objects to draw the models
therenderer = Renderers.GLBacteriumRenderer(sim)
sim.addRenderer(therenderer)
sim.pickleSteps = 20
def init(cell):
# Specify mean and distribution of initial cell size
cell.targetVol = 3.0 + random.uniform(0.0,0.5)
# Specify growth rate of cells
cell.growthRate = 1.0
# Specify initial concentration of chemical species
cell.species[:] = [0]
def specRateCL():
return '''
const float k1 = 2.f;
float x0 = species[0];
rates[0] = k1;
'''
# k1 = production rate of x0
def update(cells):
#Iterate through each cell and flag cells that reach target size for division
for (id, cell) in cells.items():
cell.color = [numpy.clip(cell.species[0]/6.0,0.0,1.0), 1.0, 0.1]
if cell.volume > cell.targetVol:
a = 1
cell.asymm = [a,1]
cell.divideFlag = True
def divide(parent, d1, d2):
# Specify target cell size that triggers cell division
d1.targetVol = 3.0 + random.uniform(0.0,0.5)
d2.targetVol = 3.0 + random.uniform(0.0,0.5)