def __call__(self, labtekL=None):
     
     if labtekL is None:
         labtekL = self.labtekL
         
     print 'BASE_DIR: ', self.baseDir
     resD = {}
     for labtek in labtekL:
         spotConfD = LabtekConfiguration().getSpotConfForLabtek(labtek)
         posL = spotConfD.keys()
         for pos in posL:
             sirna = spotConfD[pos]['sirnaId']
             gene = spotConfD[pos]['geneName']
             try:
                 spotRes = spotAnalyzer.spotAnalyzer(labtek, pos, 
                     baseDir=self.baseDir, 
                     spotConfD=spotConfD, prediction_suffix='_prediction_track.dat')
                 phenoSpotD, countL = spotRes.readPrediction()
                 id = '%s--%s' % (labtek, pos)
                 resD[id] = {'initCellCount': countL[0], 'endCellCount': countL[-1], 
                             'proliferation': float(countL[-1]) / float(countL[0]),
                             'sirna': sirna, 'gene': gene}
             except:
                 resD[id] = {'initCellCount': 0, 'endCellCount': 0, 
                             'proliferation': 0.0, 
                             'sirna':sirna, 'gene': gene}
     return resD
    def generateControlPlots(self, labtekId, control='scrambled'):
        plotDir = os.path.join(self.baseDir, labtekId, 'plots', 'controls')
        if not os.path.isdir(plotDir):
            os.makedirs(plotDir)
        
        if control == 'scrambled':
            ctrlPosL = self.lc.negCtrPosL
        elif control== 'empty':
            ctrlPosL = self.lc.emptyL            
        elif control=='incenp':
            ctrlPosL = self.lc.incenpL
        else:
            return
            
        controlDataD = {}
        controlDataRawD = {}
        controlProliferationD = {}
        controlProliferationFitD = {}

        spotConfD = LabtekConfiguration().getSpotConfForLabtek(labtekId)
        
        control_len = None
        for pos in ctrlPosL:

            try:
                id = '%s--%s' % (labtekId, pos)
                spotRes = spotAnalyzer.spotAnalyzer(labtekId, pos, baseDir=self.baseDir, 
                    spotConfD=spotConfD, prediction_suffix='_prediction_track.dat')
                phenoSpotD, countL = spotRes.readPrediction()
    
                if control_len is None:
                    control_len = len(countL)
                if countL[0] > 0:    
                    controlProliferationD[pos] = [float(countL[i])/float(countL[0]) for i in range(len(countL))]
                else:
                    controlProliferationD[pos] = [0.0 for i in range(len(countL))]
                controlProliferationFitD[pos] = spotRes.fitCellCount(controlProliferationD[pos])
                control_len = min(control_len, len(countL))                    
    
                # calculate the data for all pheno classes
                normD = spotRes.normalizePrediction(phenoSpotD, countL)
                fitPredD = spotRes.fitPrediction(normD)
    
                for pheno in phenoSpotD.keys():
                    if not controlDataRawD.has_key(pheno):
                        controlDataRawD[pheno] = {}
                    if not controlDataD.has_key(pheno):
                        controlDataD[pheno] = {}
                    controlDataRawD[pheno][pos] = normD[pheno]
                    controlDataD[pheno][pos] = fitPredD[pheno]
            except:
                print 'no data for %s' % pos

        for pheno in ['Prometaphase', 'MetaphaseAlignment', 'Shape1', 'Shape3', 'Apoptosis']:
            try:
                full_filename = os.path.join(plotDir, control + '_' + pheno + '.png') 
                self.plotBundle(controlDataD[pheno], full_filename, colorsD = None, bundlePointsD = controlDataRawD[pheno],
                                title='%s for control %s' % (pheno, control), y_max=0.4)
    
                # proliferation
                full_filename = os.path.join(plotDir, control + '_proliferation.png') 
                self.plotBundle(controlProliferationFitD, full_filename, bundlePointsD = controlProliferationD, title='proliferation for control %s' % control, y_max=5.0)
            except:
                print 'no plot for %s' % control
        return