本文整理汇总了Python中CompuCell类的典型用法代码示例。如果您正苦于以下问题:Python CompuCell类的具体用法?Python CompuCell怎么用?Python CompuCell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CompuCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateAttributes
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'] = []
示例2: step
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
示例3: start
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
示例4: updateAttributes
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)
示例5: step
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
示例6: step
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
示例7: step
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
示例8: updateAttributes
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"]
示例9: __init__
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)
示例10: step
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 )
示例11: mitosis_visualization_countdown
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
示例12: initializeElasticityLocal
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
示例13: start
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']
示例14: moveCell
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
示例15: step
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