def moveCell(self, cell, shiftVector): #we have to make two list of pixels : pixelsToDelete = [] #used to hold pixels to delete pixelsToMove = [] #used to hold pixels to move # If we try to reassign pixels in the loop where we iterate over pixel data we will corrupt the container so in the loop below all we will do is to populate the two list mentioned above pixelList = self.getCellPixelList(cell) pt = CompuCell.Point3D() print " Moving ", pixelList.numberOfPixels( ), " pixels of cell.id=", cell.id, " . Shift vector=", shiftVector for pixelTrackerData in pixelList: pt.x = pixelTrackerData.pixel.x + shiftVector.x pt.y = pixelTrackerData.pixel.y + shiftVector.y pt.z = pixelTrackerData.pixel.z + shiftVector.z # here we are making a copy of the cell print "adding pt=", pt pixelsToDelete.append(CompuCell.Point3D(pixelTrackerData.pixel)) if self.checkIfInTheLattice(pt): pixelsToMove.append(CompuCell.Point3D(pt)) # self.cellField.set(pt,cell) # Now we will move cell for pixel in pixelsToMove: # self.cellField.set(pixel,cell) self.cellField[pixel.x, pixel.y, pixel.z] = cell # Now we will delete old pixels pixelList = self.getCellPixelList(cell) pt = CompuCell.Point3D() self.mediumCell = CompuCell.getMediumCell() print " Deleting ", len(pixelsToDelete), " pixels of cell.id=", cell.id for pixel in pixelsToDelete: self.cellField[pixel.x, pixel.y, pixel.z] = self.mediumCell
def step(self,mcs): ## count down through initial phase offset for each GZ cell cells_to_grow=[] # list of cells to evaluate for growth if mcs <= self.T_double: for cell in self.cellList: if cell.type==3: # GZ cells cellDict=CompuCell.getPyAttrib(cell) if cellDict["phaseCountdown"]==0: # if cell has reached or surpassed its initial phase offset cells_to_grow.append(cell) # add cell to list of cells to evaluate for growth else: cellDict["phaseCountdown"]-=1 # count down phase offset else: for cell in self.cellList: if cell.type==3: # GZ cells cells_to_grow.append(cell) ## Grow each cell that meets criteria for growth by increasing target volume and surface parameters: count=0 if self.pixPerMCS: for cell in cells_to_grow: cell.targetVolume+=self.pixPerMCS cell.targetSurface=int(4*sqrt(cell.volume)+0.5) count+=1 else: count_timer=0 for cell in cells_to_grow: cellDict=CompuCell.getPyAttrib(cell) if cellDict["growth_timer"] < self.mcsPerPix: # if cell has not reached time to grow cellDict["growth_timer"] += 1 # add to growth timer count_timer+=1 else: # if cell has reached time to grow, increase target volume and surface cell.targetVolume+=1 cell.targetSurface=int(4*sqrt(cell.volume)+0.5) cellDict["growth_timer"] = 0 count+=1
def updateAttributes(self): ''' UpdateAttributes is inherited from MitosisSteppableBase and is called automatically by the divideCell() function. It sets the attributes of the parent and daughter cells ''' parent_cell = self.mitosisSteppable.parentCell child_cell = self.mitosisSteppable.childCell child_cell.targetVolume = child_cell.volume child_cell.lambdaVolume = parent_cell.lambdaVolume child_cell.targetSurface = child_cell.surface child_cell.lambdaSurface = parent_cell.lambdaSurface parent_cell.targetVolume = parent_cell.volume parent_cell.targetSurface = parent_cell.surface child_cell.type = parent_cell.type parent_dict = CompuCell.getPyAttrib(parent_cell) child_dict = CompuCell.getPyAttrib(child_cell) parent_dict.get('mitosis_times',[]).append(self.mcs - parent_dict.get('last_division_mcs',self.mcs)) parent_dict['last_division_mcs'] = self.mcs # Make a copy of the parent cell's dictionary and attach to child cell for key, item in parent_dict.iteritems(): child_dict[key] = deepcopy(item) child_dict['mitosis_times'] = []
def start(self): self.pt=CompuCell.Point3D() # set uniform VEGF_ext field for ECM self.tempvar=os.getcwd()+"/vasculo_steppableBasedMitosis_py_"+run_time+"_Data.txt" totaldatafilename=open(self.tempvar, "w") totaldatafilename.write("MCS\tId\tType\tVolume\tSurfaceArea\tX_Location\tY_Location\tVEGF165\tVEGF121\tTotalVEGF\tCXCL10\tCCL2\tGrowing\tArrested\tQuiescent\tApoptotic\tTotal Cell Number\n") #first row, tab delimited totaldatafilename.close() for x in range(self.dim.x): for y in range(self.dim.y): CompuCell.getConcentrationField(self.simulator,"VEGF_ext").set(self.pt,.05) for cell in self.cellList: if cell.type==1: # endothelial stalk cells cell.targetVolume=30 cell.lambdaVolume=6.0 cell.targetSurface=4*sqrt(cell.targetVolume) cell.lambdaSurface=4.0 if cell.type==2: # macrophage/inflammatory cells cell.targetVolume=40 cell.lambdaVolume=6.0 cell.targetSurface=4*sqrt(cell.targetVolume) cell.lambdaSurface=4.0 if cell.type==3: # mural/VSMC cells cell.targetVolume=50 cell.lambdaVolume=6.0 cell.targetSurface=4*sqrt(cell.targetVolume) cell.lambdaSurface=4.0 if cell.type==4: # endothelial tip cells cell.targetVolume=30 cell.lambdaVolume=6.0 cell.targetSurface=5*sqrt(cell.targetVolume) cell.lambdaSurface=8.0
def updateAttributes(self): # self.mitosisSteppable holds important dat from the mitosis parentCell = self.mitosisSteppable.parentCell childCell = self.mitosisSteppable.childCell parentCell.targetVolume/=2.0 #child inherits parent properties childCell.targetVolume = parentCell.targetVolume childCell.lambdaVolume = parentCell.lambdaVolume # randomly select one of the cells to be a different type if random()<0.5: childCell.type = parentCell.type else: childCell.type = self.DIFFERENTIATEDCONDENSING # get parent cell lists parentDict = CompuCell.getPyAttrib(parentCell) childDict = CompuCell.getPyAttrib(childCell) mcs=self.simulator.getStep() data = MitosisData(mcs, parentCell.id, parentCell.type, childCell.id, childCell.type) childDict['relatives'] = [data] parentDict['relatives'].append(data)
def step(self,mcs): for cell in self.cellList: if cell.type==3: pt=CompuCell.Point3D() for x in range (9,17): for y in range (9,17): pt.x=x pt.y=y if int(self.boundaryArray.get(pt)): print 'pt=',pt,' boundary=',int(self.boundaryArray.get(pt)) if not self.pixelAssigned: pt=CompuCell.Point3D(12,12,0) self.cellField.set(pt,self.mediumCell) self.pixelAssigned=True if mcs==3: pt=CompuCell.Point3D(12,12,0) self.cellField.set(pt,cell) print 'REASSIGNMNET COMPLETED' if mcs==4: pt=CompuCell.Point3D(12 ,10,0) self.cellField.set(pt,self.mediumCell) if mcs==5: pt=CompuCell.Point3D(12 ,11,0) self.cellField.set(pt,self.mediumCell) # print 'REASSIGNMNET COMPLETED' break
def step(self, mcs): pass # for cell in self.cellList: # cell.targetVolume+=1 # alternatively if you want to make growth a function of chemical concentration uncomment lines below and comment lines above O2field = CompuCell.getConcentrationField(self.simulator, "OXYGEN") MMPfield = CompuCell.getConcentrationField(self.simulator, "MMP") pt = CompuCell.Point3D() for cell in self.cellList: pt.x = int(cell.xCOM) pt.y = int(cell.yCOM) pt.z = int(cell.zCOM) O2Conc = O2field.get(pt) MMPConc = MMPfield.get(pt) if O2Conc < 0: print('--------~~~~~~~~~-----> O2 VERY LOW') print '------///------>', cell.targetVolume, O2Conc, MMPConc if cell.type == self.NORM and MMPConc > 1: print 'MMP CONC IS CRAZY!' # raw_input('!') cell.targetVolume -= 0.5 cell.lambdaVolume = 2 # raw_input('!-->removing a NORM cell') else: # if True: if cell.type == self.TPROL and O2Conc < 0: cell.type = self.TMIGR continue # O2Conc = np.abs(O2Conc) cell.targetVolume += 0.01 * O2Conc / ( 0.05 + O2Conc ) # you can use here any fcn of concentrationAtCOM
def step(self,mcs): pass # for cell in self.cellList: # cell.targetVolume+=1 # alternatively if you want to make growth a function of chemical concentration uncomment lines below and comment lines above O2field=CompuCell.getConcentrationField(self.simulator,"OXYGEN") MMPfield=CompuCell.getConcentrationField(self.simulator,"MMP") pt=CompuCell.Point3D() for cell in self.cellList: pt.x=int(cell.xCOM) pt.y=int(cell.yCOM) pt.z=int(cell.zCOM) O2Conc=O2field.get(pt) MMPConc=MMPfield.get(pt) if O2Conc < 0: print('--------~~~~~~~~~-----> O2 VERY LOW') print '------///------>',cell.targetVolume, O2Conc, MMPConc if cell.type == self.NORM and MMPConc > 1: print 'MMP CONC IS CRAZY!' # raw_input('!') cell.targetVolume -= 0.5 cell.lambdaVolume = 2 # raw_input('!-->removing a NORM cell') else: # if True: if cell.type == self.TPROL and O2Conc < 0: cell.type = self.TMIGR continue # O2Conc = np.abs(O2Conc) cell.targetVolume+=0.01*O2Conc / (0.05 + O2Conc) # you can use here any fcn of concentrationAtCOM
def step(self,mcs): ## find y-position of poster-most GZ cell and center of growth zone y_post=0 x_min=999 x_max=0 for cell in self.cellList: if cell.type==3: # GZ cell yCM=cell.yCM/float(cell.volume) xCM=cell.xCM/float(cell.volume) if yCM>y_post: y_post=yCM if xCM>x_max: x_max=xCM elif xCM<x_min: x_min=xCM x_center=x_min + (x_max-x_min)/2. ## count down through initial phase offset for each GZ cell and evaluate for y-position cells_to_grow=[] # list of cells to evaluate for growth if mcs <= self.T_double: for cell in self.cellList: if cell.type==3: # GZ cells cellDict=CompuCell.getPyAttrib(cell) if cellDict["phaseCountdown"]==0: # if cell has reached or surpassed its initial phase offset yCM = cell.yCM/float(cell.volume) xCM = cell.xCM/float(cell.volume) d = sqrt((xCM - x_center)**2 + (yCM - y_post)**2) if d < self.d_sig: cells_to_grow.append(cell) # add cell to list of cells to evaluate for growth else: cellDict["phaseCountdown"]-=1 # count down phase offset else: for cell in self.cellList: if cell.type==3: # GZ cells yCM=cell.yCM/float(cell.volume) xCM=cell.xCM/float(cell.volume) d = sqrt((xCM - x_center)**2 + (yCM - y_post)**2) if d < self.d_sig: cells_to_grow.append(cell) ## Grow each cell that meets criteria for growth by increasing target volume and surface parameters: count=0 if self.pixPerMCS: for cell in cells_to_grow: cell.targetVolume+=self.pixPerMCS cell.targetSurface=int(4*sqrt(cell.volume)+0.5) count+=1 else: count_timer=0 for cell in cells_to_grow: cellDict=CompuCell.getPyAttrib(cell) if cellDict["growth_timer"] < self.mcsPerPix: # if cell has not reached time to grow cellDict["growth_timer"] += 1 # add to growth timer count_timer+=1 else: # if cell has reached time to grow, increase target volume and surface cell.targetVolume+=1 cell.targetSurface=int(4*sqrt(cell.volume)+0.5) cellDict["growth_timer"] = 0 count+=1
def step(self,mcs): fieldVEGF2=CompuCell.getConcentrationField(self.simulator,self.fieldNameVEGF2) fieldGlucose=CompuCell.getConcentrationField(self.simulator,self.fieldNameGlucose) print mcs for cell in self.cellList: #print cell.volume #NeoVascular if cell.type == self.NEOVASCULAR: totalArea = 0 # pt=CompuCell.Point3D() # pt.x=int(round(cell.xCM/max(float(cell.volume),0.001))) # pt.y=int(round(cell.yCM/max(float(cell.volume),0.001))) # pt.z=int(round(cell.zCM/max(float(cell.volume),0.001))) # VEGFConcentration=fieldVEGF2.get(pt) VEGFConcentration=fieldVEGF2[int(round(cell.xCOM)),int(round(cell.yCOM)),int(round(cell.zCOM))] # cellNeighborList=CellNeighborListAuto(self.nTrackerPlugin,cell) cellNeighborList=self.getCellNeighbors(cell) for neighborSurfaceData in cellNeighborList: #Check to ensure cell neighbor is not medium if neighborSurfaceData.neighborAddress: if neighborSurfaceData.neighborAddress.type == self.VASCULAR or neighborSurfaceData.neighborAddress.type == self.NEOVASCULAR: #sum up common surface area of cell with its neighbors totalArea+=neighborSurfaceData.commonSurfaceArea #print " commonSurfaceArea:",neighborSurfaceData.commonSurfaceArea #print totalArea if totalArea < 45: #Growth rate equation cell.targetVolume+=2.0*VEGFConcentration/(0.01 + VEGFConcentration) print "totalArea", totalArea,"cell growth rate: ", 2.0*VEGFConcentration/(0.01 + VEGFConcentration),"cell Volume: ", cell.volume #Proliferating Cells if cell.type == self.PROLIFERATING: # pt=CompuCell.Point3D() # pt.x=int(round(cell.xCM/max(float(cell.volume),0.001))) # pt.y=int(round(cell.yCM/max(float(cell.volume),0.001))) # pt.z=int(round(cell.zCM/max(float(cell.volume),0.001))) # GlucoseConcentration=fieldGlucose.get(pt) GlucoseConcentration=fieldGlucose[int(round(cell.xCOM)),int(round(cell.yCOM)),int(round(cell.zCOM))] # Proliferating Cells become Necrotic when GlucoseConcentration is low if GlucoseConcentration < 0.001 and mcs>1000: cell.type = self.NECROTIC #set growth rate equation -- fastest cell cycle is 24hours or 1440 mcs--- 32voxels/1440mcs= 0.022 voxel/mcs cell.targetVolume+=0.022*GlucoseConcentration/(0.05 + GlucoseConcentration) #print "growth rate: ", 0.044*GlucoseConcentration/(0.05 + GlucoseConcentration), "GlucoseConcentration", GlucoseConcentration #Necrotic Cells if cell.type == self.NECROTIC: #sNecrotic Cells shrink at a constant rate cell.targetVolume-=0.1
def getConcentrationFieldAtCell(self, fieldName, cell): chemField = CompuCell.getConcentrationField(self.simulator, fieldName) pt = CompuCell.Point3D() pt.x = int(round(cell.xCOM)) pt.y = int(round(cell.yCOM)) pt.z = int(round(cell.zCOM)) # pt.x=int(round(cell.xCM/max(float(cell.volume),0.001))) # pt.y=int(round(cell.yCM/max(float(cell.volume),0.001))) # pt.z=int(round(cell.zCM/max(float(cell.volume),0.001))) return chemField.get(pt)
def updateAttributes(self): parentCell=self.mitosisSteppable.parentCell childCell=self.mitosisSteppable.childCell childCell.type=parentCell.type ... bionetAPI.copyBionetworkFromParent(parentCell,childCell) ... parentCellDict=CompuCell.getPyAttrib(parentCell) childCellDict=CompuCell.getPyAttrib(childCell) for key in parentCellDict: if (key!="Bionetwork"): childCellDict[key] = deepcopy(parentCellDict[key])
def updateAttributes(self): self.parentCell.targetVolume /= 2.0 # reducing parent target volume self.cloneParent2Child() parentARF = CompuCell.getPyAttrib(self.parentCell)["ARF"] childDict = CompuCell.getPyAttrib(self.childCell) childDict["ARF"] = parentARF + ((random.gauss(0.5, 0.17) - 0.5) * 0.1 ) # child cell slightly mutates ARF if childDict["ARF"] >= 0.8: self.childCell.type = self.RESISTENTBACTERIA else: self.childCell.type = self.REGULARBACTERIA
def step(self, mcs): global e MMPsecretor = self.getFieldSecretor("MMP") Isecretor = self.getFieldSecretor("I") GFsecretor = self.getFieldSecretor("GF") self.fieldNameMMP = 'MMP' self.fieldNameI = 'I' fieldMMP = CompuCell.getConcentrationField(self.simulator, self.fieldNameMMP) fieldI = CompuCell.getConcentrationField(self.simulator, self.fieldNameI) for cell in self.cellList: if cell.type == self.CANCER: x = random.randint(0, 4) MMPc = fieldMMP[int(round(cell.xCOM)), int(round(cell.yCOM)), int(round(cell.zCOM))] Ic = fieldI[int(round(cell.xCOM)), int(round(cell.yCOM)), int(round(cell.zCOM))] if mcs > 5: A = 2 - (2 * (-MMPc + 2 * Ic)) I1 = A else: A = x I1 = x MMPsecretor.secreteOutsideCellAtBoundaryOnContactWith( cell, A, [self.C1]) Isecretor.secreteOutsideCellAtBoundaryOnContactWith( cell, I1, [self.C1]) MMPsecretor.secreteOutsideCellAtBoundaryOnContactWith( cell, A, [self.LAMININ]) Isecretor.secreteOutsideCellAtBoundaryOnContactWith( cell, I1, [self.LAMININ]) GFsecretor.uptakeInsideCell(cell, 0.1, 0.1) if cell.type == self.L_LYSED: GFsecretor.secreteInsideCell(cell, 0.5) MMPsecretor.uptakeInsideCell(cell, 1.0, 1.0) Isecretor.uptakeInsideCell(cell, 0.5, 1.0) if cell.type == self.C_LYSED: GFsecretor.secreteInsideCellAtBoundary(cell, 1.0) MMPsecretor.uptakeInsideCell(cell, 1.5, 1.0) Isecretor.uptakeInsideCell(cell, 0.5, 1.0) if cell.type == self.C1: GFsecretor.secreteInsideCellAtBoundaryOnContactWith( cell, 2.5, [self.C_LYSED])
def updateAttributes(self): childCell = self.mitosisSteppable.childCell parentCell = self.mitosisSteppable.parentCell childCell.type = parentCell.type parentCell.targetVolume = tVol childCell.targetVolume = tVol childCell.lambdaVolume = parentCell.lambdaVolume; # inherite properties from parent cells self.copySBMLs(_fromCell=parentCell,_toCell=childCell) childCellDict=CompuCell.getPyAttrib(childCell) parentCellDict=CompuCell.getPyAttrib(parentCell) childCellDict["D"]=random.uniform(0.9,1.0)*parentCellDict["D"] childCellDict["N"]=random.uniform(0.9,1.0)*parentCellDict["N"] childCellDict["B"]=random.uniform(0.9,1.0)*parentCellDict["B"] childCellDict["R"]=random.uniform(0.9,1.0)*parentCellDict["R"]
def step(self, mcs): if mcs == 10: shiftVector = CompuCell.Point3D(20, 20, 0) for cell in self.cellList: self.moveCell(cell, shiftVector) if mcs == 20: pt = CompuCell.Point3D(50, 50, 0) self.createNewCell(2, pt, 5, 5, 1) if mcs == 30: for cell in self.cellList: self.deleteCell(cell)
def finish(self): for cell in self.cellList: dataList = CompuCell.getPyAttrib(cell) if len(dataList['relatives'])>0: print "MITOTIC DATA FOR CELL ID:",cell.id for data in dataList['relatives']: print data
def mitosis_visualization_countdown(self): for cell in self.cellListByType(4): # Mitosis cell cellDict = CompuCell.getPyAttrib(cell) if cellDict['mitosisVisualizationTimer'] <= 0: cell.type = cellDict['returnToCellType'] else: cellDict['mitosisVisualizationTimer'] -= 1
def start(self): for cell in self.cellList: vasculo_attributes=CompuCell.getPyAttrib(cell) if cell.type==1: vasculo_attributes['cell.receptor.VEGFR1']=100 vasculo_attributes['cell.receptor.VEGFR2']=1000
def __init__(self,_simulator,_frequency=10): SteppablePy.__init__(self,_frequency) self.simulator=_simulator self.nTrackerPlugin=CompuCell.getNeighborTrackerPlugin() self.inventory=self.simulator.getPotts().getCellInventory() self.cellList=CellList(self.inventory)
def initializeElasticityLocal(self): for cell in self.cellList: elasticityDataList=self.getElasticityDataList(cell) for elasticityData in elasticityDataList: # visiting all elastic links of 'cell' targetLength=elasticityData.targetLength elasticityData.targetLength=6.0 elasticityData.lambdaLength=200.0 elasticityNeighbor=elasticityData.neighborAddress # now we set up elastic link data stored in neighboring cell neighborElasticityData=None neighborElasticityDataList=self.getElasticityDataList(elasticityNeighbor) for neighborElasticityDataTmp in neighborElasticityDataList: if not CompuCell.areCellsDifferent(neighborElasticityDataTmp.neighborAddress,cell): neighborElasticityData=neighborElasticityDataTmp break if neighborElasticityData is None: print "None Type returned. Problems with FemDataNeighbors initialization or sets of elasticityNeighborData are corrupted" sys.exit() neighborElasticityData.targetLength=6.0 neighborElasticityData.lambdaLength=200.0
def moveCell(self, cell, shiftVector): #we have to make two list of pixels : pixelsToDelete=[] #used to hold pixels to delete pixelsToMove=[] #used to hold pixels to move # If we try to reassign pixels in the loop where we iterate over pixel data we will corrupt the container so in the loop below all we will do is to populate the two list mentioned above pixelList=self.getCellPixelList(cell) pt=CompuCell.Point3D() print " Moving ",pixelList.numberOfPixels()," pixels of cell.id=",cell.id," . Shift vector=",shiftVector for pixelTrackerData in pixelList: pt.x = pixelTrackerData.pixel.x + shiftVector.x pt.y = pixelTrackerData.pixel.y + shiftVector.y pt.z = pixelTrackerData.pixel.z + shiftVector.z # here we are making a copy of the cell print "adding pt=",pt pixelsToDelete.append(CompuCell.Point3D(pixelTrackerData.pixel)) if self.checkIfInTheLattice(pt): pixelsToMove.append(CompuCell.Point3D(pt)) # self.cellField.set(pt,cell) # Now we will move cell for pixel in pixelsToMove: # self.cellField.set(pixel,cell) self.cellField[pixel.x,pixel.y,pixel.z]=cell # Now we will delete old pixels pixelList=self.getCellPixelList(cell) pt=CompuCell.Point3D() self.mediumCell=CompuCell.getMediumCell() print " Deleting ",len(pixelsToDelete)," pixels of cell.id=",cell.id for pixel in pixelsToDelete: self.cellField[pixel.x,pixel.y,pixel.z]=self.mediumCell
def step(self, mcs): # for cell in self.cellList: # cell.targetVolume+=1 # alternatively if you want to make growth a function of chemical concentration uncomment lines below and comment lines above # field=CompuCell.getConcentrationField(self.simulator,"PUT_NAME_OF_CHEMICAL_FIELD_HERE") # pt=CompuCell.Point3D() field = CompuCell.getConcentrationField(self.simulator, "R") ##### comPt = CompuCell.Point3D() ##### for cell in self.cellList: if cell.type == self.P: ##### comPt.x = int(cell.xCOM) comPt.y = int(cell.yCOM) comPt.z = int(cell.zCOM) concentrationAtCOM = field.get(comPt) cell.targetVolume += 0.01 * concentrationAtCOM # you can use here any fcn of concentrationAtCOM
def initializeElasticityLocal(self): for cell in self.cellList: elasticityDataList = self.getElasticityDataList(cell) for elasticityData in elasticityDataList: # visiting all elastic links of 'cell' targetLength = elasticityData.targetLength elasticityData.targetLength = 6.0 elasticityData.lambdaLength = 200.0 elasticityNeighbor = elasticityData.neighborAddress # now we set up elastic link data stored in neighboring cell neighborElasticityData = None neighborElasticityDataList = self.getElasticityDataList( elasticityNeighbor) for neighborElasticityDataTmp in neighborElasticityDataList: if not CompuCell.areCellsDifferent( neighborElasticityDataTmp.neighborAddress, cell): neighborElasticityData = neighborElasticityDataTmp break if neighborElasticityData is None: print "None Type returned. Problems with FemDataNeighbors initialization or sets of elasticityNeighborData are corrupted" sys.exit() neighborElasticityData.targetLength = 6.0 neighborElasticityData.lambdaLength = 200.0
def __init__(self,_simulator,_frequency=1): SteppablePy.__init__(self,_frequency) self.simulator=_simulator self.volumeLocalFlexPlugin=CompuCell.getVolumeLocalFlexPlugin() self.inventory=self.simulator.getPotts().getCellInventory() self.cellList=CellList(self.inventory)
def step(self,mcs): for cell in self.cellList: mitDataList=CompuCell.getPyAttrib(cell) if len(mitDataList) > 0: print "MITOSIS DATA FOR CELL ID",cell.id for mitData in mitDataList: print mitData
def step(self, mcs): # ######### Update all bionetwork integrator(s) ########### bionetAPI.timestepBionetworks() bionetAPI.printBionetworkState(1) # ######## Implement cell growth by increasing target volume ########## for cell in self.cellList: dictionaryAttrib = CompuCell.getPyAttrib( cell ) cell.targetVolume = cell.volume + 0.1*dictionaryAttrib["InitialVolume"] # ###### Retrieve delta values and set cell bionetwork template libraries according to delta concentration ######## for cell in self.cellList: currentDelta = bionetAPI.getBionetworkValue( "DN_di", cell.id ) if( currentDelta > 0.5 ): if self.cellTypeMap[cell.type] == "LowDelta": bionetAPI.setBionetworkValue( "TemplateLibrary", "HighDelta", cell.id ) else: if self.cellTypeMap[cell.type] == "HighDelta": bionetAPI.setBionetworkValue( "TemplateLibrary", "LowDelta", cell.id ) # ####### Set all cell dbari values as a function of neighbor delta values ######### for cell in self.cellList: weightedSumOfNeighborDeltaValues = 0.0 neighborContactAreas = bionetAPI.getNeighborContactAreas( cell.id ) neighborDeltaValues = bionetAPI.getNeighborProperty( "DN_di", cell.id ) for neighborID in neighborContactAreas.keys(): weightedSumOfNeighborDeltaValues += (neighborContactAreas[neighborID] * neighborDeltaValues[neighborID]) bionetAPI.setBionetworkValue( "DN_dbari", weightedSumOfNeighborDeltaValues/cell.surface, cell.id )
def findMinMax(self, conField, dim): import CompuCell pt = CompuCell.Point3D() maxCon = 0 minCon = 0 for k in range(dim[2]): for j in range(dim[1]): for i in range(dim[0]): pt.x = i pt.y = j pt.z = k con = float(conField.get(pt)) if maxCon < con: maxCon = con if minCon > con: minCon = con # Make sure that the concentration is positive if minCon < 0: minCon = 0 return (minCon, maxCon)
def start(self): #Loading model Name = 'DeltaNotch' Key = 'DN' simulationDir=os.path.dirname (os.path.abspath( __file__ )) Path= os.path.join(simulationDir,'DN_Collier.sbml') Path=os.path.abspath(Path) # normalizing path IntegrationStep = 0.2 bionetAPI.loadSBMLModel(Name, Path, Key, IntegrationStep) bionetAPI.addSBMLModelToTemplateLibrary(Name,'TypeA') bionetAPI.initializeBionetworks() #Initial conditions import random state={} #dictionary to store state veriables of the SBML model for cell in self.cellList: if (cell): state['D'] = random.uniform(0.9,1.0) state['N'] = random.uniform(0.9,1.0) bionetAPI.setBionetworkState(cell.id,'DeltaNotch',state) cellDict=CompuCell.getPyAttrib(cell) cellDict['D']=state['D'] cellDict['N']=state['N']
def step(self,mcs): ## find y-position of poster-most segment boundary, y_border y_border=0 for cell in self.cellList: if cell.type==2: # segment 2 cell--most posterior segment yCM=cell.yCM/float(cell.volume) if yCM>y_border: y_border=yCM ## count down through initial phase offset for each GZ cell and evaluate for y-position cells_to_grow=[] # list of cells to evaluate for growth if mcs <= self.T_double: for cell in self.cellList: if cell.type==3: # GZ cells cellDict=CompuCell.getPyAttrib(cell) if cellDict["phaseCountdown"]==0: # if cell has reached or surpassed its initial phase offset yCM = cell.yCM/float(cell.volume) if yCM > y_border + self.y_sig: cells_to_grow.append(cell) # add cell to list of cells to evaluate for growth else: cellDict["phaseCountdown"]-=1 # count down phase offset else: for cell in self.cellList: if cell.type==3: # GZ cells yCM=cell.yCM/float(cell.volume) if yCM > y_border + self.y_sig: cells_to_grow.append(cell) ## Grow each cell that meets criteria for growth by increasing target volume and surface parameters: count=0 if self.pixPerMCS: for cell in cells_to_grow: cell.targetVolume+=self.pixPerMCS cell.targetSurface=int(4*sqrt(cell.volume)+0.5) count+=1 else: count_timer=0 for cell in cells_to_grow: cellDict=CompuCell.getPyAttrib(cell) if cellDict["growth_timer"] < self.mcsPerPix: # if cell has not reached time to grow cellDict["growth_timer"] += 1 # add to growth timer count_timer+=1 else: # if cell has reached time to grow, increase target volume and surface cell.targetVolume+=1 cell.targetSurface=int(4*sqrt(cell.volume)+0.5) cellDict["growth_timer"] = 0 count+=1
def mitosisVisualizationCountdown(self): for cell in self.cellList: if cell.type == 4: # if Mitosis cell cellDict = CompuCell.getPyAttrib(cell) if cellDict['mitosisVisualizationTimer'] <= 0: cell.type = cellDict['returnToCellType'] else: cellDict['mitosisVisualizationTimer'] -= 1
def __init__(self, _simulator, _frequency, _x0, _y0, _xf, _yf, _reporter): SteppableBasePy.__init__(self, _simulator, _frequency) self.pixelTrackerPlugin = CompuCell.getPixelTrackerPlugin() self.x0 = _x0; self.xf = _xf self.y0 = _y0; self.yf = _yf self.reporter = _reporter
def find_GB_division_count(self): division_count = 0 for cell in self.cellList: if cell: cellDict = CompuCell.getPyAttrib(cell) division_count += cellDict['divided'] cellDict['divided'] = 0 return division_count
def generateEllipsoid(self,_semiMinorAxis,_semiMedianAxis,_semiMajorAxis): pt=CompuCell.Point3D(self.dim.x/2,self.dim.y/2,self.dim.z/2) cell=self.potts.createCell() cell.type=1 for x,y,z in self.everyPixel(): if (x-self.dim.x/2.0)**2/_semiMinorAxis**2+(y-self.dim.y/2.0)**2/_semiMajorAxis**2+(z-self.dim.z/2.0)**2/_semiMedianAxis**2 <1: self.cellField[x,y,z]=cell
def outputField(self,_fieldName,_fileName): field=CompuCell.getConcentrationField(self.simulator,_fieldName) pt=CompuCell.Point3D() if field: try: fileHandle=open(_fileName,"w") except IOError: print "Could not open file ", _fileName," for writing. Check if you have necessary permissions" print "dim.x=",self.dim.x for i in xrange(self.dim.x): for j in xrange(self.dim.y): for k in xrange(self.dim.z): pt.x=i pt.y=j pt.z=k fileHandle.write("%d\t%d\t%d\t%f\n"%(pt.x,pt.y,pt.z,field.get(pt)))
def step(self, mcs): self.scalarFieldG.clear() for cell in self.cellList: if cell: cellDict = CompuCell.getPyAttrib(cell) self.scalarFieldG[cell] = cellDict['GTPase']
def updateAttributes(self): parentCell = self.mitosisSteppable.parentCell childCell = self.mitosisSteppable.childCell childCell.targetVolume = childCell.volume childCell.lambdaVolume = parentCell.lambdaVolume childCell.targetSurface = childCell.surface childCell.lambdaSurface = parentCell.lambdaSurface parentCell.targetVolume = parentCell.volume parentCell.targetSurface = parentCell.surface childCell.type = parentCell.type parentDict = CompuCell.getPyAttrib(parentCell) childDict = CompuCell.getPyAttrib(childCell) ### Make a copy of the parent cell's dictionary and attach to child cell for key, item in parentDict.items(): childDict[key] = deepcopy(parentDict[key])
def updateAttributes(self): parentCell=self.mitosisSteppable.parentCell childCell=self.mitosisSteppable.childCell childCell.targetVolume = childCell.volume childCell.lambdaVolume = parentCell.lambdaVolume childCell.targetSurface = childCell.surface childCell.lambdaSurface = parentCell.lambdaSurface parentCell.targetVolume = parentCell.volume parentCell.targetSurface = parentCell.surface childCell.type = parentCell.type parentDict=CompuCell.getPyAttrib(parentCell) childDict=CompuCell.getPyAttrib(childCell) ### Make a copy of the parent cell's dictionary and attach to child cell for key, item in parentDict.items(): childDict[key]=deepcopy(parentDict[key])
def deleteSBMLFromCell(self,_modelName='',_cell=None): import CompuCell dict_attrib=CompuCell.getPyAttrib(_cell) try: sbmlDict=dict_attrib['SBMLSolver'] del sbmlDict[_modelName] except LookupError,e: pass
def step(self,mcs): self.scalarFieldG.clear() for cell in self.cellList: if cell: cellDict=CompuCell.getPyAttrib(cell) self.scalarFieldG[cell] = cellDict['GTPase']
def setStepSizeForCell(self, _modelName='',_cell=None,_stepSize=1.0): import CompuCell dict_attrib = CompuCell.getPyAttrib(_cell) try: sbmlSolver=dict_attrib['SBMLSolver'][_modelName] except LookupError,e: return
def step(self, mcs): field = CompuCell.getConcentrationField(self.simulator, "Sactivator") comPt = CompuCell.Point3D() meanCon = 0.0 for cell in self.cellList: if cell.id == 1: comPt.x = int(round(cell.xCOM)) comPt.y = int(round(cell.yCOM)) comPt.z = int(round(cell.zCOM)) con = field.get(comPt) meanCon += con # get concentration at comPt self.Activator.addDataPoint("Activator", mcs, meanCon)
def deleteSBMLFromCell(self, _modelName='', _cell=None): import CompuCell dict_attrib = CompuCell.getPyAttrib(_cell) try: sbmlDict = dict_attrib['SBMLSolver'] del sbmlDict[_modelName] except LookupError, e: pass
def setStepSizeForCell(self, _modelName='', _cell=None, _stepSize=1.0): import CompuCell dict_attrib = CompuCell.getPyAttrib(_cell) try: sbmlSolver = dict_attrib['SBMLSolver'][_modelName] except LookupError, e: return
def step(self, mcs): field = CompuCell.getConcentrationField(self.simulator, "Firstinhibitor") fielt = CompuCell.getConcentrationField(self.simulator, "Sactivator") fiell = CompuCell.getConcentrationField(self.simulator, "Secondinhibitor") comPt = CompuCell.Point3D() # concentrationAI=field.get(comPt) #concentrationA=fielt.get(comPt) for cell in self.cellList: if cell.type == self.UD or cell.type == self.G: if mcs > 0 and field[ cell.xCOM, cell.yCOM, cell.zCOM] < 0.5 and fiell[ cell.xCOM, cell.yCOM, cell.zCOM] > 0.5 and fielt[cell.xCOM, cell.yCOM, cell.zCOM] > 20: cell.type = self.OF if mcs > 0 and fiell[ cell.xCOM, cell.yCOM, cell.zCOM] < 0.5 and field[ cell.xCOM, cell.yCOM, cell.zCOM] > 0.5 and fielt[cell.xCOM, cell.yCOM, cell.zCOM] > 20: cell.type = self.OS if mcs > 0 and fiell[ cell.xCOM, cell.yCOM, cell.zCOM] < 0.5 and field[ cell.xCOM, cell.yCOM, cell.zCOM] < 0.5 and fielt[cell.xCOM, cell.yCOM, cell.zCOM] > 20: if random() < 0.5: cell.type = self.OS else: cell.type = self.OF #concentration=field[int(round(cell.xCOM)),int(round(cell.yCOM)),int(round(cell.zCOM))] #type here the code that will run every _frequency MCS for cell in self.cellList: currentCellPosition = cell.xCM / float(cell.volume) currentCellPositiony = cell.yCM / float(cell.volume) firstinhi = field[cell.xCOM, cell.yCOM, cell.zCOM] secondinhi = fiell[cell.xCOM, cell.yCOM, cell.zCOM] sactivator = fielt[cell.xCOM, cell.yCOM, cell.zCOM] print("id=", cell.id, "posx= ", currentCellPosition, "posy= ", currentCellPositiony, "Fi= ", firstinhi, "Si= ", secondinhi, "Sac= ", sactivator)
def step(self,mcs): cells_to_divide=[] for cell in self.cellList: dictionaryAttrib = CompuCell.getPyAttrib( cell ) if cell.volume > dictionaryAttrib["DivideVolume"]: cells_to_divide.append(cell) for cell in cells_to_divide: self.divideCellRandomOrientation(cell)
def step(self,mcs): for cell in self.cellList: #pyAttrib=cell.pyAttrib pyAttrib=CompuCell.getPyAttrib(cell) pyAttrib[0]=[cell.id*mcs,cell.id*(mcs-1)] if not mcs % 20: print "CELL ID modified=",pyAttrib," true=",cell.id, print " ref count=",sys.getrefcount(pyAttrib), print " ref count=",sys.getrefcount(pyAttrib)
def step(self, mcs): cells_to_divide = [] for cell in self.cellList: dictionaryAttrib = CompuCell.getPyAttrib(cell) if cell.volume > dictionaryAttrib["DivideVolume"]: cells_to_divide.append(cell) for cell in cells_to_divide: self.divideCellRandomOrientation(cell)
def deleteCell(self, cell): # pixelsToDelete=self.getCopyOfCellPixels(cell,SteppableBasePy.CC3D_FORMAT) # returns list of Point3D pixelsToDelete = self.getCopyOfCellPixels( cell, SteppableBasePy.TUPLE_FORMAT) # returns list of tuples self.mediumCell = CompuCell.getMediumCell() for pixel in pixelsToDelete: print "CELL.volume=", cell.volume self.cellField[pixel[0], pixel[1], pixel[2]] = self.mediumCell
def deleteCell(self,cell): # pixelsToDelete=self.getCopyOfCellPixels(cell,SteppableBasePy.CC3D_FORMAT) # returns list of Point3D pixelsToDelete=self.getCopyOfCellPixels(cell,SteppableBasePy.TUPLE_FORMAT) # returns list of tuples self.mediumCell=CompuCell.getMediumCell() for pixel in pixelsToDelete: print "CELL.volume=",cell.volume self.cellField[pixel[0],pixel[1],pixel[2]]=self.mediumCell
def step(self,mcs): self.scalarFieldDelta.clear() self.scalarFieldNotch.clear() for cell in self.cellList: if cell: cellDict=CompuCell.getPyAttrib(cell) self.scalarFieldDelta[cell]=cellDict['D'] self.scalarFieldNotch[cell]=cellDict['N']
def deleteSBMLFromCellTypes(self,_modelName,_types=[]): import CompuCell for cell in self.cellListByType(*_types): dict_attrib=CompuCell.getPyAttrib(cell) try: sbmlDict=dict_attrib['SBMLSolver'] del sbmlDict[_modelName] except LookupError,e: pass
def start(self): self.y_EN_pos=self.find_posterior_EN_stripe() self.y_EN_ant=self.find_anterior_EN_stripe() self.y_GZ_border=self.find_y_GZ_mitosis_border() for cell in self.cellList: region=self.assign_cell_region(cell) # self.initiate_cell_volume(cell) ## Initiates cells with new volumes to distribute mitoses in time cellDict = CompuCell.getPyAttrib(cell) cellDict["growth_timer"]=self.attach_growth_timer(cell) ## attached a countdown timer for cell growth
def deleteSBMLFromCellTypes(self, _modelName, _types=[]): import CompuCell for cell in self.cellListByType(*_types): dict_attrib = CompuCell.getPyAttrib(cell) try: sbmlDict = dict_attrib['SBMLSolver'] del sbmlDict[_modelName] except LookupError, e: pass
def step(self, mcs): fieldMMP = CompuCell.getConcentrationField(self.simulator, self.fieldNameMMP) fieldI = CompuCell.getConcentrationField(self.simulator, self.fieldNameI) fieldGF = CompuCell.getConcentrationField(self.simulator, self.fieldNameGF) comPt = CompuCell.Point3D() state = {} global c global ck global mcsOut global c_value global varii for cell in self.cellList: #collagen fibre elongation if cell.type == self.C1 and mcs < 5: cell.targetVolume += 0.8 cell.lambdaVolume = 20.0 if cell.type == self.CANCER: neighborList = self.getCellNeighborDataList(cell) k = neighborList.commonSurfaceAreaWithCellTypes( cell_type_list=[3]) s = cell.surface g = (s - k) / 40 GFc = fieldGF[int(round(cell.xCOM)), int(round(cell.yCOM)), int(round(cell.zCOM))] cell.targetVolume += varii * ( (g / 4 + (GFc / 7)) / 3) #Growth rate cell.lambdaVolume = 20.0 #this term can be changed in correlation with stiffness of neighbors, as a fn of neighbor type,no etc if int(round(cell.xCOM)) > 97 or int(round( cell.xCOM)) < 3 or int(round(cell.yCOM)) > 97 or int( round(cell.yCOM)) < 3: self.deleteCell(cell) c += 1 if c == 1: mcsOut = mcs ck = c if ck != 0 and mcs % 5 == 0: c_value.append(ck)
def grow_cell(self, cell): cellDict = CompuCell.getPyAttrib(cell) region = cellDict["region"] r_grow = self.r_grow_list[region] if cellDict["growth_timer"] >= 1: if cell.targetVolume <= self.Vmax: cell.targetVolume += int(cellDict["growth_timer"]) cellDict["growth_timer"] = 0 else: cellDict["growth_timer"] += r_grow
def make_mitosis_list(self): mitosis_list = [] for cell in self.cellList: cellDict = CompuCell.getPyAttrib(cell) region = cellDict["region"] mitosis_probability = self.r_mitosis_list[region] / self.window if mitosis_probability >= random(): if cell.volume >= self.Vmin_divide: mitosis_list.append(cell) return mitosis_list
def start(self): self.y_EN_pos = self.find_posterior_EN_stripe() self.y_EN_ant = self.find_anterior_EN_stripe() self.y_GZ_border = self.find_y_GZ_mitosis_border() for cell in self.cellList: region = self.assign_cell_region(cell) # self.initiate_cell_volume(cell) ## Initiates cells with new volumes to distribute mitoses in time cellDict = CompuCell.getPyAttrib(cell) cellDict["growth_timer"] = self.attach_growth_timer( cell) ## attached a countdown timer for cell growth