Attachment 'RountreeSteppablePresentation.py'

Download

   1 import CompuCell, CompuCellSetup, PlayerPython
   2 from PySteppables import SteppableBasePy
   3 from math import sqrt
   4 import time
   5 import random           
   6             
   7 class CellPropertyandModifier(SteppableBasePy):
   8     def __init__(self,_simulator,_frequency=50):
   9         SteppableBasePy.__init__(self,_simulator,_frequency)
  10         
  11     def start(self):
  12         for cell in self.cellList:          #### initializing color property
  13             cell.targetVolume=25
  14             cell.lambdaVolume=10
  15             cell.targetSurface=4*sqrt(cell.targetVolume)
  16             cell.lamdaSurface=10
  17             
  18             cell_attributes=CompuCell.getPyAttrib(cell)
  19             cell_attributes['property red']=False
  20             cell_attributes['property green']=False
  21             cell_attributes['property blue']=False
  22             
  23     def step(self,mcs):
  24         for cell in self.cellList:
  25             cell_attributes=CompuCell.getPyAttrib(cell)
  26             cell_attributes['property green']=False
  27             cell_attributes['property blue']=False
  28 ############Begin code for simulations without apoptosis
  29             if random.random()<.5:
  30                 cell_attributes['property green']=True
  31             else:
  32                 cell_attributes['property blue']=True
  33 ############End code for simulations without apoptosis
  34 
  35 
  36 class CellTypeVisualizer(SteppableBasePy):
  37     def __init__(self,_simulator,_frequency=50):
  38         SteppableBasePy.__init__(self,_simulator,_frequency)
  39         self.runBeforeMCS=True
  40         
  41     def start(self):
  42         self.cellTypeField=CompuCellSetup.createScalarFieldCellLevelPy("CellPropertyField")
  43         
  44     def step(self,mcs):
  45         PlayerPython.clearScalarValueCellLevel(self.cellTypeField)
  46         for cell in self.cellList:
  47             cell_attributes=CompuCell.getPyAttrib(cell)
  48             if cell_attributes['property red']==True:
  49                 PlayerPython.fillScalarValueCellLevel(self.cellTypeField,cell,2.0)
  50             elif cell_attributes['property green']==True:
  51                 PlayerPython.fillScalarValueCellLevel(self.cellTypeField,cell,1.0)
  52             elif cell_attributes['property blue']==True: ### could use just "else"
  53                 PlayerPython.fillScalarValueCellLevel(self.cellTypeField,cell,0.01)
  54 
  55 
  56 
  57 
  58 class ApoptosisCheck(SteppableBasePy):
  59     def __init__(self,_simulator,_frequency=10):
  60         SteppableBasePy.__init__(self,_simulator,_frequency)
  61         
  62     def start(self):
  63         for cell in self.cellList:              #### initializing apoptotic property
  64             cell_attributes=CompuCell.getPyAttrib(cell)
  65             cell_attributes['property red']=False
  66             
  67     def step(self,mcs):
  68         for cell in self.cellList:
  69             cell_attributes=CompuCell.getPyAttrib(cell)
  70             if cell_attributes['property red']==False and random.random()>.9995:
  71                 cell_attributes['property green']=False
  72                 cell_attributes['property blue']=False
  73                 cell_attributes['property red']=True                
  74 
  75 
  76 
  77 class Apoptosis(SteppableBasePy):
  78     def __init__(self,_simulator,_frequency=10):
  79         SteppableBasePy.__init__(self,_simulator,_frequency)
  80         self.mitosisSteppable=CompuCell.MitosisSteppable()
  81         self.mitosisSteppable.init(_simulator)
  82         
  83     def step(self,mcs):
  84         self.randomcelldivisionlist=[]
  85         target_total_cell_volume=0
  86         actual_total_cell_volume=0
  87         for cell in self.cellList:
  88             cell_attributes=CompuCell.getPyAttrib(cell)
  89             if cell_attributes['property red']==True and cell.volume>6:
  90                 self.randomcelldivisionlist.append(cell)
  91                 
  92         for dividecell in self.randomcelldivisionlist:
  93             if self.mitosisSteppable.doDirectionalMitosisRandomOrientation(dividecell):
  94                 self.updateAttributes()
  95             
  96 ##    def step(self,mcs):
  97 ##        self.randomcelldivisionlist=[]
  98 ##        [self.randomcelldivisionlist.append(cell) for cell in self.cellList if (CompuCell.getPyAttrib(cell)['apoptotic']==True and cell.volume>7)]
  99 ##        [self.updateAttributes() for dividecell in self.randomcelldivisionlist if self.mitosisSteppable.doDirectionalMitosisRandomOrientation(dividecell)]
 100         
 101     def updateAttributes(self):
 102         childCell=self.mitosisSteppable.childCell
 103         parentCell=self.mitosisSteppable.parentCell
 104         parentCell.targetVolume=parentCell.targetVolume/2
 105         childCell.targetVolume=parentCell.targetVolume
 106         parentCell.targetSurface=4*sqrt(parentCell.targetVolume)
 107         childCell.targetSurface=4*sqrt(childCell.targetVolume)
 108         childCell.lambdaVolume=parentCell.lambdaVolume
 109         childCell.lambdaSurface=parentCell.lambdaSurface
 110         childCell.type=parentCell.type
 111         CompuCell.getPyAttrib(childCell).update(CompuCell.getPyAttrib(parentCell))
 112 
 113 
 114 
 115 class PropertySwitcher(SteppableBasePy):
 116     def __init__(self,_simulator,_frequency=10):
 117         SteppableBasePy.__init__(self,_simulator,_frequency)
 118 
 119     def step(self,mcs):
 120         for cell in self.cellList:
 121             cell_attributes=CompuCell.getPyAttrib(cell)
 122             if cell_attributes['property red']==True:
 123                 cell.type=2
 124 
 125 
 126 
 127 class Output(SteppableBasePy):
 128     def __init__(self,_simulator,_frequency=10):
 129         SteppableBasePy.__init__(self,_simulator,_frequency)
 130 
 131     def step(self,mcs):
 132         x=time.clock()
 133         target_total_cell_volume=0
 134         actual_total_cell_volume=0
 135         for cell in self.cellList:
 136             target_total_cell_volume+=cell.targetVolume
 137             actual_total_cell_volume+=cell.volume
 138         print "Output,               Time Taken=", time.clock()-x
 139         print " Total Target Volume is: ", target_total_cell_volume
 140         print " Total Actual Volume is: ", actual_total_cell_volume
 141 
 142         
 143 class MassConservationViaMacrophage(SteppableBasePy):       
 144     def __init__(self,_simulator,_frequency=10):
 145         SteppableBasePy.__init__(self,_simulator,_frequency)
 146     def step(self,mcs):
 147         for cell in self.cellList:
 148             cell_attributes=CompuCell.getPyAttrib(cell)
 149             if cell_attributes['property red']==True and cell.volume<=6:
 150                 neighborchoice=random.choice(list(self.getCellNeighbors(cell)))
 151                 if neighborchoice.neighborAddress and CompuCell.getPyAttrib(neighborchoice.neighborAddress)['property green']==True:
 152                     neighbor_attributes=CompuCell.getPyAttrib(neighborchoice.neighborAddress)
 153                     if neighbor_attributes['property red']!=True:
 154                         neighborchoice.neighborAddress.targetVolume+=cell.targetVolume
 155                         neighborchoice.neighborAddress.targetSurface=4*sqrt(neighborchoice.neighborAddress.targetVolume)
 156                         cell.targetVolume=0
 157                         cell.targetSurface=0
 158         
 159 
 160 class Mitosis(SteppableBasePy):
 161     def __init__(self,_simulator,_frequency=10):
 162         SteppableBasePy.__init__(self,_simulator,_frequency)
 163         self.mitosisSteppable=CompuCell.MitosisSteppable()
 164         self.mitosisSteppable.init(_simulator)
 165         
 166     def step(self,mcs):
 167         self.randomcelldivisionlist=[]
 168         for cell in self.cellList:
 169             cell_attributes=CompuCell.getPyAttrib(cell)
 170             if cell_attributes['property red']!=True and cell.volume>100:
 171                 self.randomcelldivisionlist.append(cell)
 172         for dividecell in self.randomcelldivisionlist:
 173             if self.mitosisSteppable.doDirectionalMitosisRandomOrientation(dividecell):
 174                 self.updateAttributes() 
 175 
 176     def updateAttributes(self):
 177         childCell=self.mitosisSteppable.childCell
 178         parentCell=self.mitosisSteppable.parentCell
 179         parentCell.targetVolume=parentCell.targetVolume/2
 180         childCell.targetVolume=parentCell.targetVolume
 181         parentCell.targetSurface=4*sqrt(parentCell.targetVolume)
 182         childCell.targetSurface=4*sqrt(childCell.targetVolume)
 183         childCell.lambdaVolume=parentCell.lambdaVolume
 184         childCell.lambdaSurface=parentCell.lambdaSurface
 185         childCell.type=parentCell.type
 186         CompuCell.getPyAttrib(childCell).update(CompuCell.getPyAttrib(parentCell))

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2011-08-17 14:42:10, 320.0 KB) [[attachment:Adhesion Parameter Values.doc]]
  • [get | view] (2011-08-17 14:46:22, 9560.3 KB) [[attachment:CNV-P-T1-T2 .pptx]]
  • [get | view] (2011-08-17 14:36:43, 8.4 KB) [[attachment:CellDiffusionCalculatorSteppable.py]]
  • [get | view] (2011-09-10 20:31:09, 2273.1 KB) [[attachment:CellDraw_1.5.0_presentation_2011.pdf]]
  • [get | view] (2011-08-08 22:09:40, 6.5 KB) [[attachment:Heiko3_O2_ps.zip]]
  • [get | view] (2011-08-18 17:51:04, 57547.3 KB) [[attachment:MergingCC3DandSBWSBML.pdf]]
  • [get | view] (2011-08-18 17:51:42, 2724.4 KB) [[attachment:MergingCC3DandSBWSBML.pptx]]
  • [get | view] (2011-08-18 17:52:58, 43497.5 KB) [[attachment:MergingCC3DandSBWSBML.zip]]
  • [get | view] (2011-08-17 20:57:30, 3.4 KB) [[attachment:RountreeInitializerPresentation.py]]
  • [get | view] (2011-08-17 20:57:05, 8.2 KB) [[attachment:RountreeSteppablePresentation.py]]
  • [get | view] (2011-08-18 17:57:53, 0.2 KB) [[attachment:SimpleOscillator.jan]]
  • [get | view] (2011-08-18 17:58:00, 4.0 KB) [[attachment:SimpleOscillator.sbml]]
  • [get | view] (2011-08-17 14:36:27, 3.7 KB) [[attachment:cellsort2D_negative_J.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.