Beispiel #1
0
    def run(self, printProgress=PRINT_PROGRESS):
        '''
        Runs the statistic specified in self._analysis (from analysisDef) and returns an object of class Result
        
        '''
        #Should be there for batch runs.. Should never happen from GUI..
        if self._statClass == None:
            self._handleMissingStat()
            return None

        if DebugConfig.USE_PROFILING:
            from gold.util.Profiler import Profiler
            profiler = Profiler()
            resDict = {}
            profiler.run('resDict[0] = StatJob.run(self, printProgress=printProgress)', globals(), locals())
            res = resDict[0]
        else:
            res = StatJob.run(self, printProgress=printProgress)
        
        res.setAnalysis(self._analysis)
        res.setAnalysisText(str(self._analysis))
        
        ResultsMemoizer.flushStoredResults()
        
        if DebugConfig.USE_PROFILING:
            profiler.printStats()
            if DebugConfig.USE_CALLGRAPH and self._galaxyFn:
                profiler.printLinkToCallGraph(['profile_AnalysisDefJob'], self._galaxyFn)
        
        return res
Beispiel #2
0
    def execute(cls, choices, galaxyFn=None, username=''):

        # DebugUtil.insertBreakPoint()
        cls._setDebugModeIfSelected(choices)

        choices_queryTrack = choices.queryTrack
        choices_gsuite = choices.gsuite
        genome = choices.genome
        # queryTrackNameAsList = ExternalTrackManager.getPreProcessedTrackFromGalaxyTN(genome, choices.queryTrack,
        #                                                                              printErrors=False,
        #                                                                              printProgress=False)
        # gsuite = getGSuiteFromGalaxyTN(choices.gsuite)

        analysisBins = UserBinMixin.getUserBinSource(choices)

        import quick.gsuite.GuiBasedTsFactory as factory
        queryTS = factory.getSingleTrackTS(genome, choices_queryTrack)
        refTS = factory.getFlatTracksTS(genome, choices_gsuite)

        ts = TrackStructureV2()
        realTS = TrackStructureV2()
        realTS["query"] = queryTS
        realTS["reference"] = refTS
        randQueryTS = queryTS
        randTvProvider = cls.createTrackViewProvider(choices, refTS, analysisBins, genome)
        localAnalysis = randTvProvider.supportsLocalAnalysis()
        randRefTS = getRandomizedVersionOfTs(refTS, randTvProvider)

        hypothesisKeyList = [sts.metadata["title"] for sts in randRefTS.values()]
        for hypothesisKey in hypothesisKeyList:
            realTS = TrackStructureV2()
            realTS["query"] = queryTS
            realTS["reference"] = refTS[hypothesisKey]
            randTS = TrackStructureV2()
            randTS["query"] = randQueryTS
            randTS["reference"] = randRefTS[hypothesisKey]
            hypothesisTS = TrackStructureV2()
            hypothesisTS["real"] = realTS
            hypothesisTS["rand"] = randTS
            ts[hypothesisKey] = hypothesisTS
        analysisSpec = cls._prepareAnalysisWithHypothesisTests(choices, localAnalysis)
        if DebugConfig.USE_PROFILING:
            from gold.util.Profiler import Profiler
            profiler = Profiler()
            resDict = {}
            profiler.run('resDict[0] = doAnalysis(analysisSpec, analysisBins, ts)', globals(), locals())
            res = resDict[0]
            result = res.getGlobalResult()['Result']
            profiler.printStats()
            if DebugConfig.USE_CALLGRAPH and galaxyFn:
                profiler.printLinkToCallGraph(['profile_AnalysisDefJob'], galaxyFn)
        else:
            result = doAnalysis(analysisSpec, analysisBins, ts).getGlobalResult()["Result"]
        for trackTitle, res in result.iteritems():
            print '{}: {}<br>'.format(trackTitle, repr(res.getResult()))