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 USE_PROFILING: 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 USE_PROFILING: profiler.printStats() return res
def runProfile(self): from gold.util.Profiler import Profiler profiler = Profiler() import socket import os try: profiler.run('self.run()', globals(), locals()) except: pass profiler.dumpStats(str(os.getpid()) + "-" + str(socket.gethostname()))
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
def setUp(self): if not self.VERBOSE: sys.stdout = StringIO.StringIO() if not hasattr(ProfiledIntegrationTest, '_svnRevision'): ProfiledIntegrationTest._svnRevision = ProfilingStorage.getSvnRevision( ) #print ProfiledIntegrationTest._svnRevision, self._getId(), ProfilingStorage.isStored(self._getId(), ProfiledIntegrationTest._svnRevision) if ProfiledIntegrationTest._svnRevision != None and \ not ProfilingStorage.isStored(self._getId(), ProfiledIntegrationTest._svnRevision): self._profiler = Profiler() else: self._profiler = None
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()))
class ProfiledIntegrationTest(TestCaseWithImprovedAsserts): VERBOSE = False def setUp(self): if not self.VERBOSE: sys.stdout = StringIO.StringIO() if not hasattr(ProfiledIntegrationTest, '_svnRevision'): ProfiledIntegrationTest._svnRevision = ProfilingStorage.getSvnRevision( ) #print ProfiledIntegrationTest._svnRevision, self._getId(), ProfilingStorage.isStored(self._getId(), ProfiledIntegrationTest._svnRevision) if ProfiledIntegrationTest._svnRevision != None and \ not ProfilingStorage.isStored(self._getId(), ProfiledIntegrationTest._svnRevision): self._profiler = Profiler() else: self._profiler = None def _getId(self): return self.id().split('.')[-1] def _usesProfiling(self): return self._profiler is not None def _runWithProfiling(self, runStr, symbolDict={}): aeval = Interpreter() if symbolDict: aeval.symtable.update(symbolDict) if not self._usesProfiling(): return aeval(runStr) else: print 'Running with profiling..' res = self._profiler.run('aeval(%s)' % runStr, globals, locals) self._profiler.printStats() return res def _storeProfile(self, diskMemo=False): if self.VERBOSE or not self._usesProfiling(): return ProfilingStorage.parseAndStoreProfile(sys.stdout.getvalue(), self._getId(),\ ProfiledIntegrationTest._svnRevision, diskMemo)
def setUp(self): if not self.VERBOSE: sys.stdout = StringIO.StringIO() if not hasattr(ProfiledIntegrationTest, '_svnRevision'): ProfiledIntegrationTest._svnRevision = ProfilingStorage.getSvnRevision() #print ProfiledIntegrationTest._svnRevision, self._getId(), ProfilingStorage.isStored(self._getId(), ProfiledIntegrationTest._svnRevision) if ProfiledIntegrationTest._svnRevision != None and \ not ProfilingStorage.isStored(self._getId(), ProfiledIntegrationTest._svnRevision): self._profiler = Profiler() else: self._profiler = None
class ProfiledIntegrationTest(TestCaseWithImprovedAsserts): VERBOSE = False def setUp(self): if not self.VERBOSE: sys.stdout = StringIO.StringIO() if not hasattr(ProfiledIntegrationTest, '_svnRevision'): ProfiledIntegrationTest._svnRevision = ProfilingStorage.getSvnRevision() #print ProfiledIntegrationTest._svnRevision, self._getId(), ProfilingStorage.isStored(self._getId(), ProfiledIntegrationTest._svnRevision) if ProfiledIntegrationTest._svnRevision != None and \ not ProfilingStorage.isStored(self._getId(), ProfiledIntegrationTest._svnRevision): self._profiler = Profiler() else: self._profiler = None def _getId(self): return self.id().split('.')[-1] def _usesProfiling(self): return self._profiler is not None def _runWithProfiling(self, runStr, globals, locals): if not self._usesProfiling(): return eval(runStr, globals, locals) else: print 'Running with profiling..' res = self._profiler.run(runStr, globals, locals) self._profiler.printStats() return res def _storeProfile(self, diskMemo=False): if self.VERBOSE or not self._usesProfiling(): return ProfilingStorage.parseAndStoreProfile(sys.stdout.getvalue(), self._getId(),\ ProfiledIntegrationTest._svnRevision, diskMemo)