def execute(cls, choices, galaxyFn=None, username=''): ''' Is called when execute-button is pushed by web-user. Should print output as HTML to standard out, which will be directed to a results page in Galaxy history. If getOutputFormat is anything else than HTML, the output should be written to the file with path galaxyFn. If needed, StaticFile can be used to get a path where additional files can be put (e.g. generated image files). choices is a list of selections made by web-user in each options box. ''' regSpec, binSpec = UserBinMixin.getRegsAndBinsSpec(choices) genome = choices.Genome #trackNames = [choices[choiceIndex].split(':') for choiceIndex in [2,4,6]] #trackNames = [x.split(':') for x in [choices.Track1, choices.Track2, choices.Track3]] trackNames = cls.getAllChosenTracks(choices) print trackNames #for tnIndex, choiceIndex in zip(range(3),[2,4,6]): # tn = choices[choiceIndex].split(':') # trackNames[tnIndex] = tn #trackNames[tnIndex] = ExternalTrackManager.getPreProcessedTrackFromGalaxyTN(genome, tn) \ # if ExternalTrackManager.isGalaxyTrack(tn) \ # else tn #analysisDef = 'dummy [trackNameIntensity=%s]-> ThreeWayBpOverlapStat' % '|'.join(trackNames[2]) #Do not preserve any pair-wise relations', 'Preserve pair-wise relation between Track 1 and Track 3', 'Preserve pair-wise relation between Track 2 and Track 3'] #['Base pair coverage of all track combinations', 'Inclusion structure between tracks', 'Observed versus expected overlap with various relations preserved', 'Hypothesis testing on multi-track relations'] if choices.Analysis == 'Base pair coverage of all track combinations': analysisDef = 'dummy -> ThreeWayBpOverlapStat' elif choices.Analysis == 'Inclusion structure between tracks': analysisDef = 'dummy -> ThreeWayTrackInclusionBpOverlapStat' elif choices.Analysis == 'Observed versus expected overlap with various relations preserved': pass elif choices.Analysis == 'Factors of observed versus expected overlap with various relations preserved': analysisDef = 'Dummy [rawStatistic=ThreeWayExpectedWithEachPreserveCombinationBpOverlapStat] [referenceResDictKey=preserveNone] -> GenericFactorsAgainstReferenceResDictKeyStat' elif choices.Analysis == 'Hypothesis testing on multi-track relations': randOption = cls._getRandomizationAnalysisOption(choices) numResamplingsOption = '[numResamplings=%s]' % choices.NumResamplings #assert len(trackNames) == 3, trackNames #currently, due to ThreeTrackBpsCoveredByAllTracksStat #analysisDef = 'dummy [tail=different] [rawStatistic=ThreeTrackBpsCoveredByAllTracksStat] %s %s -> RandomizationManagerStat' % (randOption, numResamplingsOption) resDictKey = '1' * (len(trackNames)) analysisDef = 'dummy [tail=different] [rawStatistic=SingleValExtractorStat] [childClass=ThreeWayBpOverlapStat] [resultKey=%s] %s %s -> RandomizationManagerStat' % ( resDictKey, randOption, numResamplingsOption) print analysisDef elif choices.Analysis == 'Coverage depth of multiple tracks along the genome': analysisDef = 'dummy -> ThreeWayCoverageDepthStat' else: raise Exception(choices.Analysis) analysisDef = 'dummy [extraTracks=%s] ' % '&'.join( ['|'.join(tn) for tn in trackNames[2:]]) + analysisDef #GalaxyInterface.run(trackNames[0], trackNames[1], analysisDef, regSpec, binSpec, genome, galaxyFn, trackNames[2], printRunDescription=False) GalaxyInterface.run(trackNames[0], trackNames[1], analysisDef, regSpec, binSpec, genome, galaxyFn, printRunDescription=False)
def execute(cls, choices, galaxyFn=None, username=''): ''' Is called when execute-button is pushed by web-user. Should print output as HTML to standard out, which will be directed to a results page in Galaxy history. If getOutputFormat is anything else than HTML, the output should be written to the file with path galaxyFn. If needed, StaticFile can be used to get a path where additional files can be put (e.g. generated image files). choices is a list of selections made by web-user in each options box. ''' regSpec, binSpec = UserBinSelector.getRegsAndBinsSpec(choices) genome = choices.Genome #trackNames = [choices[choiceIndex].split(':') for choiceIndex in [2,4,6]] #trackNames = [x.split(':') for x in [choices.Track1, choices.Track2, choices.Track3]] trackNames = cls.getAllChosenTracks(choices) print trackNames #for tnIndex, choiceIndex in zip(range(3),[2,4,6]): # tn = choices[choiceIndex].split(':') # trackNames[tnIndex] = tn #trackNames[tnIndex] = ExternalTrackManager.getPreProcessedTrackFromGalaxyTN(genome, tn) \ # if ExternalTrackManager.isGalaxyTrack(tn) \ # else tn #analysisDef = 'dummy [trackNameIntensity=%s]-> ThreeWayBpOverlapStat' % '|'.join(trackNames[2]) #Do not preserve any pair-wise relations', 'Preserve pair-wise relation between Track 1 and Track 3', 'Preserve pair-wise relation between Track 2 and Track 3'] #['Base pair coverage of all track combinations', 'Inclusion structure between tracks', 'Observed versus expected overlap with various relations preserved', 'Hypothesis testing on multi-track relations'] if choices.Analysis == 'Base pair coverage of all track combinations': analysisDef = 'dummy -> ThreeWayBpOverlapStat' elif choices.Analysis == 'Inclusion structure between tracks': analysisDef = 'dummy -> ThreeWayTrackInclusionBpOverlapStat' elif choices.Analysis == 'Observed versus expected overlap with various relations preserved': pass elif choices.Analysis == 'Factors of observed versus expected overlap with various relations preserved': analysisDef = 'Dummy [rawStatistic=ThreeWayExpectedWithEachPreserveCombinationBpOverlapStat] [referenceResDictKey=preserveNone] -> GenericFactorsAgainstReferenceResDictKeyStat' elif choices.Analysis == 'Hypothesis testing on multi-track relations': randOption = cls._getRandomizationAnalysisOption(choices) numResamplingsOption = '[numResamplings=%s]' % choices.NumResamplings #assert len(trackNames) == 3, trackNames #currently, due to ThreeTrackBpsCoveredByAllTracksStat #analysisDef = 'dummy [tail=different] [rawStatistic=ThreeTrackBpsCoveredByAllTracksStat] %s %s -> RandomizationManagerStat' % (randOption, numResamplingsOption) resDictKey = '1'*(len(trackNames)) analysisDef = 'dummy [tail=different] [rawStatistic=SingleValExtractorStat] [childClass=ThreeWayBpOverlapStat] [resultKey=%s] %s %s -> RandomizationManagerStat' % (resDictKey, randOption, numResamplingsOption) print analysisDef else: raise Exception(choices.Analysis) analysisDef = 'dummy [extraTracks=%s] ' % '&'.join(['|'.join(tn) for tn in trackNames[2:] ]) + analysisDef #GalaxyInterface.run(trackNames[0], trackNames[1], analysisDef, regSpec, binSpec, genome, galaxyFn, trackNames[2], printRunDescription=False) GalaxyInterface.run(trackNames[0], trackNames[1], analysisDef, regSpec, binSpec, genome, galaxyFn, printRunDescription=False)
def execute(cls, choices, galaxyFn=None, username=''): '''Is called when execute-button is pushed by web-user. Should print output as HTML to standard out, which will be directed to a results page in Galaxy history. If needed, StaticFile can be used to get a path where additional files can be put (e.g. generated image files). choices is a list of selections made by web-user in each options box. ''' genome = choices[0] nmer = choices[1].lower() regSpec = choices[2] analysisRegions = parseRegSpec(regSpec, genome) binSize = cls._calcBinSize(nmer, analysisRegions) binSpec = '*' if binSize is None else str( binSize ) numBins = len( AutoBinner(analysisRegions, binSize) ) from quick.application.GalaxyInterface import GalaxyInterface from quick.util.GenomeInfo import GenomeInfo trackName1 = GenomeInfo.getPropertyTrackName(genome, 'nmer') + [str(len(nmer))+'-mers',nmer] trackName2 = [''] analysisDef = 'Counts: The number of track1-points -> CountPointStat' #regSpec = '*' #print 'Using binSize: ',binSpec #print 'TN1: ',trackName1 from gold.result.HtmlCore import HtmlCore print str(HtmlCore().styleInfoBegin(styleClass='debug')) GalaxyInterface.run(trackName1, trackName2, analysisDef, regSpec, binSpec, genome, galaxyFn) print str(HtmlCore().styleInfoEnd()) plotFileNamer = GalaxyRunSpecificFile(['0','CountPointStat_Result_gwplot.pdf'], galaxyFn) textualDataFileNamer = GalaxyRunSpecificFile(['0','CountPointStat_Result.bedgraph'], galaxyFn) core = HtmlCore() core.paragraph('Inspect nmer frequency variation as a %s or as underlying %s.</p>' % ( plotFileNamer.getLink('plot'), textualDataFileNamer.getLink('textual data') )) core.divider() core.paragraph('The occurrence frequency of your specified nmer ("%s") has been computed along the genome, within your specified analysis region ("%s").' % (nmer, regSpec)) core.paragraph('The analysis region was divided into %i bins, based on calculations trying to find appropriate bin size (get enough data per bin and restrict maximum number of bins).' % numBins) trackName1modified = trackName1[0:-2] + trackName1[-1:] preSelectedAnalysisUrl = createHyperBrowserURL(genome, trackName1modified,[''], analysis='Counts',method='auto',region=regSpec, binsize=binSpec) core.divider() core.paragraph('If you do not find the inferred bin size to be appropriate, you can set this manually in a ' + str(HtmlCore().link('new analysis', preSelectedAnalysisUrl)) + '.') print str(core)
def execute(self, printHtmlBeginEnd=True, printTrackNamesTable=True): print GalaxyInterface.getHtmlBeginForRuns(self._galaxyFn) core = HtmlCore() if printTrackNamesTable: core.divBegin('trackNames') dataDict = OrderedDict([(x, []) for x in self._trackNames]) tblExpandable = True if len(self._trackNames) < 11: tblExpandable = False core.tableFromDictionary(dataDict, ['Tracks under analysis'], tableId="resTable", expandable=tblExpandable) # core.tableHeader(['Tracks under analysis:']) # for trackName in self._trackNames: # core.tableLine([trackName]) # core.tableFooter() core.divEnd() print core try: results = GalaxyInterface.run(self._tracks[0], self._tracks[1], self.getAnalysisDefinitionString(), self._regSpec, self._binSpec, self._genome, self._galaxyFn, printRunDescription=False, printHtmlBeginEnd=printHtmlBeginEnd, fromMainTool=False) if self.hasVisualization(): print self.visualizeResults(results) # except: # pass finally: core2 = HtmlCore() core2.hideToggle(styleClass='infomessagesmall') print core2 print GalaxyInterface.getHtmlEndForRuns()
def execute(cls, choices, galaxyFn=None, username=''): '''Is called when execute-button is pushed by web-user. Should print output as HTML to standard out, which will be directed to a results page in Galaxy history. If needed, StaticFile can be used to get a path where additional files can be put (e.g. generated image files). choices is a list of selections made by web-user in each options box. ''' from quick.application.UserBinSource import parseRegSpec genome = choices[0] nmer = choices[1].lower() regSpec = choices[2] analysisRegions = parseRegSpec(regSpec, genome) binSize = cls._calcBinSize(nmer, analysisRegions) binSpec = '*' if binSize is None else str(binSize) numBins = len(AutoBinner(analysisRegions, binSize)) from quick.application.GalaxyInterface import GalaxyInterface from quick.util.GenomeInfo import GenomeInfo trackName1 = GenomeInfo.getPropertyTrackName( genome, 'nmer') + [str(len(nmer)) + '-mers', nmer] trackName2 = [''] analysisDef = 'Counts: The number of track1-points -> CountPointStat' #regSpec = '*' #print 'Using binSize: ',binSpec #print 'TN1: ',trackName1 from proto.hyperbrowser.HtmlCore import HtmlCore print str(HtmlCore().styleInfoBegin(styleClass='debug')) GalaxyInterface.run(trackName1, trackName2, analysisDef, regSpec, binSpec, genome, galaxyFn) print str(HtmlCore().styleInfoEnd()) plotFileNamer = GalaxyRunSpecificFile( ['0', 'CountPointStat_Result_gwplot.pdf'], galaxyFn) textualDataFileNamer = GalaxyRunSpecificFile( ['0', 'CountPointStat_Result.bedgraph'], galaxyFn) core = HtmlCore() core.paragraph( 'Inspect k-mer frequency variation as a %s or as underlying %s.</p>' % (plotFileNamer.getLink('plot'), textualDataFileNamer.getLink('textual data'))) core.divider() core.paragraph( 'The occurrence frequency of your specified k-mer ("%s") has been computed along the genome, within your specified analysis region ("%s").' % (nmer, regSpec)) core.paragraph( 'The analysis region was divided into %i bins, based on calculations trying to find appropriate bin size (get enough data per bin and restrict maximum number of bins).' % numBins) trackName1modified = trackName1[0:-2] + trackName1[-1:] preSelectedAnalysisUrl = createHyperBrowserURL(genome, trackName1modified, [''], analysis='Counts', method='__custom__', region=regSpec, binsize=binSpec) core.divider() core.paragraph( 'If you do not find the inferred bin size to be appropriate, you can set this manually in a ' + str(HtmlCore().link('new analysis', preSelectedAnalysisUrl)) + '.') print str(core)