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. ''' HtmlCore().begin() core = HtmlCore() histChoices = choices.history chosenResDictKey = choices.stat[:choices.stat.find(' [')] useGlobal = True if choices.localOrGlobal == 'Global results' else False imputeNAs = True if choices.allowMissing == 'Yes' else False resultsLists, historyNames = cls._getResultsLists(histChoices) allLocalKeys = cls._getResDictAndLocalKeys(resultsLists)[1] if useGlobal: if choices.sepByTrack == 'Yes': if choices.rowLabels == 'First track': firstColLabel = 'Track_1' elif choices.rowLabels == 'Second track': firstColLabel = 'Track_2' elif choices.rowLabels == 'All tracks': firstColLabel = 'Tracks' else: #No firstColLabel = 'Statistic' else: firstColLabel = 'Local region' if choices.printColLabels == 'No': columnLabels = None else: #Yes if choices.colLabelType.startswith('Short'): columnLabels = cls._getColumnLabels(choices, 'short') elif choices.colLabelType.startswith('Long'): columnLabels = cls._getColumnLabels(choices, 'long') else: #Custom columns columnLabels = choices.colLabels.split('|') if useGlobal: resColl = GlobalResultCollection(chosenResDictKey, imputeNAs, \ naChar=choices.denoteMissing, \ firstColLabel=firstColLabel) else: resColl = LocalResultCollection(chosenResDictKey, allLocalKeys, imputeNAs, \ naChar=choices.denoteMissing, \ firstColLabel=firstColLabel) outFile = open(galaxyFn, 'w') if choices.printInfo == 'Yes': print>>outFile, '# Concatenated %s results for statistic: ' \ % ('global' if choices.localOrGlobal == 'Global results' else 'local') \ + chosenResDictKey from urllib import unquote for i, resultList in enumerate(resultsLists): for j, oneResult in enumerate(resultList): trackNames = oneResult.getTrackNames() tracks = [unquote(trackNames[i][-1]) if trackNames[1] else '' \ for i in range(len(trackNames))] if choices.sepByTrack in [None, '', 'No']: label = chosenResDictKey else: if choices.rowLabels == 'First track': label = tracks[0] elif choices.rowLabels == 'Second track': label = tracks[1] elif choices.rowLabels == 'All tracks': label = ' & '.join(tracks) resColl[label] = oneResult outFile.write(resColl.getTabularStrRepresentation(columnLabels)) outFile.close()
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. ''' import numpy numpy.seterr(all='raise') cls._setDebugModeIfSelected(choices) # DebugUtil.insertBreakPoint(username=username, currentUser='******') genome = choices.genome analysisQuestion = choices.analysisName similaryStatClassName = choices.similarityFunc if choices.similarityFunc else GSuiteStatUtils.T5_RATIO_OF_OBSERVED_TO_EXPECTED_OVERLAP summaryFunc = choices.summaryFunc if choices.summaryFunc else 'average' reverse = 'Yes' if choices.reversed else 'No' gsuite = getGSuiteFromGalaxyTN(choices.gsuite) regSpec, binSpec = UserBinMixin.getRegsAndBinsSpec(choices) analysisBins = GalaxyInterface._getUserBinSource(regSpec, binSpec, genome=genome) tracks = [ Track(x.trackName, trackTitle=x.title) for x in gsuite.allTracks() ] trackTitles = CommonConstants.TRACK_TITLES_SEPARATOR.join( [quote(x.title, safe='') for x in gsuite.allTracks()]) additionalResultsDict = OrderedDict() additionalAttributesDict = OrderedDict() if analysisQuestion in [cls.Q1, cls.Q2, cls.Q3]: additionalAttributesDict = cls.getSelectedAttributesForEachTrackDict( choices.additionalAttributes, gsuite) #additional analysis stats = [CountStat, CountElementStat] additionalResultsDict = runMultipleSingleValStatsOnTracks( gsuite, stats, analysisBins, queryTrack=None) if analysisQuestion == cls.Q1: analysisSpec = AnalysisSpec( GSuiteRepresentativenessOfTracksRankingsWrapperStat) analysisSpec.addParameter( 'pairwiseStatistic', GSuiteStatUtils. PAIRWISE_STAT_LABEL_TO_CLASS_MAPPING[similaryStatClassName]) analysisSpec.addParameter( 'summaryFunc', GSuiteStatUtils.SUMMARY_FUNCTIONS_MAPPER[summaryFunc]) analysisSpec.addParameter('reverse', reverse) analysisSpec.addParameter('ascending', 'No') analysisSpec.addParameter('trackTitles', trackTitles) analysisSpec.addParameter('queryTracksNum', len(tracks)) results = doAnalysis(analysisSpec, analysisBins, tracks).getGlobalResult() gsPerTrackResultsModel = GSuitePerTrackResultModel( results, ['Similarity to rest of tracks in suite (%s)' % summaryFunc], additionalResultsDict=additionalResultsDict, additionalAttributesDict=additionalAttributesDict) if choices.leadAttribute and choices.leadAttribute != GSuiteConstants.TITLE_COL: columnTitles, decoratedResultsDict = \ gsPerTrackResultsModel.generateColumnTitlesAndResultsDict(choices.leadAttribute) else: columnTitles, decoratedResultsDict = \ gsPerTrackResultsModel.generateColumnTitlesAndResultsDict() core = HtmlCore() core.begin() core.divBegin(divId='results-page') core.divBegin(divClass='results-section') core.header(analysisQuestion) topTrackTitle = results.keys()[0] core.paragraph(''' The track "%s" is the most representative track of the GSuite with %s %s similarity to the rest of the tracks as measured by "%s" track similarity measure. ''' % (topTrackTitle, results[topTrackTitle], summaryFunc, similaryStatClassName)) addTableWithTabularAndGsuiteImportButtons( core, choices, galaxyFn, cls.Q1_SHORT, decoratedResultsDict, columnTitles, gsuite=gsuite, results=results, gsuiteAppendAttrs=['similarity_score'], sortable=True) # plot columnInd = 0 if choices.leadAttribute and choices.leadAttribute != GSuiteConstants.TITLE_COL: columnInd = 1 res = GSuiteTracksCoincidingWithQueryTrackTool.drawPlot( results, additionalResultsDict, 'Similarity to rest of tracks in suite (%s)' % summaryFunc, columnInd=columnInd) core.line(res) core.divEnd() core.divEnd() core.end() # elif analysisQuestion == cls.Q2: # analysisSpec = AnalysisSpec(GSuiteRepresentativenessOfTracksRankingsWrapperStat) # analysisSpec.addParameter('pairwiseStatistic', GSuiteStatUtils.PAIRWISE_STAT_LABEL_TO_CLASS_MAPPING[similaryStatClassName]) # analysisSpec.addParameter('summaryFunc', GSuiteStatUtils.SUMMARY_FUNCTIONS_MAPPER[summaryFunc]) # analysisSpec.addParameter('reverse', reverse) # analysisSpec.addParameter('ascending', 'Yes') # analysisSpec.addParameter('trackTitles', trackTitles) # results = doAnalysis(analysisSpec, analysisBins, tracks).getGlobalResult() # # gsPerTrackResultsModel = GSuitePerTrackResultModel( # results, ['Similarity to rest of tracks in suite (%s)' % summaryFunc], # additionalResultsDict=additionalResultsDict, # additionalAttributesDict=additionalAttributesDict) # if choices.leadAttribute and choices.leadAttribute != GSuiteConstants.TITLE_COL: # columnTitles, decoratedResultsDict = \ # gsPerTrackResultsModel.generateColumnTitlesAndResultsDict(choices.leadAttribute) # else: # columnTitles, decoratedResultsDict = \ # gsPerTrackResultsModel.generateColumnTitlesAndResultsDict() # # core = HtmlCore() # core.begin() # core.divBegin(divId='results-page') # core.divBegin(divClass='results-section') # core.header(analysisQuestion) # topTrackTitle = results.keys()[0] # core.paragraph(''' # The track "%s" is the most atypical track of the GSuite with %s %s similarity to the rest of the tracks # as measured by the "%s" track similarity measure. # ''' % (topTrackTitle, strWithNatLangFormatting(results[topTrackTitle]), summaryFunc, similaryStatClassName)) # # core.tableFromDictionary(results, columnNames=['Track title', 'Similarity to rest of tracks in suite (' + summaryFunc+')'], sortable=False) # # from quick.util import CommonFunctions # rawDataURIList = CommonFunctions.getHyperlinksForRawTableData( # dataDict=decoratedResultsDict, colNames=columnTitles, # tableId="resultsTable", galaxyFn=galaxyFn) # core.tableFromDictionary(decoratedResultsDict, columnNames=columnTitles, sortable=True, # tableId='resultsTable', addInstruction=True, # addRawDataSelectBox=True, rawDataURIList=rawDataURIList) # # core.tableFromDictionary(decoratedResultsDict, columnNames=columnTitles, sortable=True, tableId='resultsTable') # # columnInd = 0 # if choices.leadAttribute and choices.leadAttribute != GSuiteConstants.TITLE_COL: # columnInd = 1 # res = GSuiteTracksCoincidingWithQueryTrackTool.drawPlot( # results, additionalResultsDict, # 'Similarity to rest of tracks in suite (%s)' % summaryFunc, # columnInd=columnInd) # core.line(res) # core.divEnd() # core.divEnd() # core.end() # # if choices.addResults == 'Yes': # GSuiteStatUtils.addResultsToInputGSuite( # gsuite, results, ['Similarity_score'], # cls.extraGalaxyFn[GSUITE_EXPANDED_WITH_RESULT_COLUMNS_FILENAME]) elif analysisQuestion == cls.Q3: mcfdrDepth = choices.mcfdrDepth if choices.mcfdrDepth else \ AnalysisDefHandler(REPLACE_TEMPLATES['$MCFDR$']).getOptionsAsText().values()[0][0] analysisDefString = REPLACE_TEMPLATES[ '$MCFDRv3$'] + ' -> GSuiteRepresentativenessOfTracksRankingsAndPValuesWrapperStat' analysisSpec = AnalysisDefHandler(analysisDefString) analysisSpec.setChoice('MCFDR sampling depth', mcfdrDepth) analysisSpec.addParameter('assumptions', 'PermutedSegsAndIntersegsTrack') analysisSpec.addParameter( 'rawStatistic', SummarizedInteractionWithOtherTracksV2Stat.__name__) analysisSpec.addParameter( 'pairwiseStatistic', GSuiteStatUtils. PAIRWISE_STAT_LABEL_TO_CLASS_MAPPING[similaryStatClassName]) analysisSpec.addParameter( 'summaryFunc', GSuiteStatUtils.SUMMARY_FUNCTIONS_MAPPER[summaryFunc]) analysisSpec.addParameter('tail', 'right-tail') analysisSpec.addParameter('trackTitles', trackTitles) results = doAnalysis(analysisSpec, analysisBins, tracks).getGlobalResult() core = HtmlCore() gsPerTrackResultsModel = GSuitePerTrackResultModel( results, [ 'Similarity to rest of tracks in suite (%s)' % summaryFunc, 'P-value' ], additionalResultsDict=additionalResultsDict, additionalAttributesDict=additionalAttributesDict) if choices.leadAttribute and choices.leadAttribute != GSuiteConstants.TITLE_COL: columnTitles, decoratedResultsDict = \ gsPerTrackResultsModel.generateColumnTitlesAndResultsDict(choices.leadAttribute) else: columnTitles, decoratedResultsDict = \ gsPerTrackResultsModel.generateColumnTitlesAndResultsDict() core.begin() core.divBegin(divId='results-page') core.divBegin(divClass='results-section') core.header(analysisQuestion) topTrackTitle = results.keys()[0] core.paragraph(''' The track "%s" has the lowest P-value of %s corresponding to %s %s similarity to the rest of the tracks as measured by "%s" track similarity measure. ''' % (topTrackTitle, strWithNatLangFormatting(results[topTrackTitle][1]), strWithNatLangFormatting(results[topTrackTitle][0]), summaryFunc, similaryStatClassName)) # core.tableFromDictionary(results, columnNames=['Track title', 'Similarity to rest of tracks in suite (' + summaryFunc+')', 'P-value'], sortable=False) addTableWithTabularAndGsuiteImportButtons( core, choices, galaxyFn, cls.Q3_SHORT, decoratedResultsDict, columnTitles, gsuite=gsuite, results=results, gsuiteAppendAttrs=['similarity_score', 'p_value'], sortable=True) core.divEnd() core.divEnd() core.end() else: # Q4 mcfdrDepth = choices.mcfdrDepth if choices.mcfdrDepth else \ AnalysisDefHandler(REPLACE_TEMPLATES['$MCFDR$']).getOptionsAsText().values()[0][0] analysisDefString = REPLACE_TEMPLATES[ '$MCFDRv3$'] + ' -> CollectionSimilarityHypothesisWrapperStat' analysisSpec = AnalysisDefHandler(analysisDefString) analysisSpec.setChoice('MCFDR sampling depth', mcfdrDepth) analysisSpec.addParameter('assumptions', 'PermutedSegsAndIntersegsTrack') analysisSpec.addParameter('rawStatistic', 'MultitrackSummarizedInteractionV2Stat') analysisSpec.addParameter( 'pairwiseStatistic', GSuiteStatUtils. PAIRWISE_STAT_LABEL_TO_CLASS_MAPPING[similaryStatClassName]) analysisSpec.addParameter( 'summaryFunc', GSuiteStatUtils.SUMMARY_FUNCTIONS_MAPPER[summaryFunc]) analysisSpec.addParameter('multitrackSummaryFunc', 'avg') # should it be a choice? analysisSpec.addParameter('tail', 'right-tail') results = doAnalysis(analysisSpec, analysisBins, tracks).getGlobalResult() pval = results['P-value'] observed = results['TSMC_MultitrackSummarizedInteractionV2Stat'] significanceLevel = 'strong' if pval < 0.01 else ( 'weak' if pval < 0.05 else 'no') core = HtmlCore() core.begin() core.divBegin(divId='results-page') core.divBegin(divClass='results-section') core.header(analysisQuestion) core.paragraph(''' The tracks in the suite show %s significance in their collective similarity (average similarity of a track to the rest) of %s and corresponding p-value of %s, as measured by "%s" track similarity measure. ''' % (significanceLevel, strWithNatLangFormatting(observed), strWithNatLangFormatting(pval), similaryStatClassName)) core.divEnd() core.divEnd() core.end() print str(core)
def execute(choices, galaxyFn=None, username=''): file = choices.file columnX = choices.columnX columnY = choices.columnY plotType = choices.plotType axesScaleX = choices.axesScaleX axesScaleY = choices.axesScaleY plotSeries = choices.plotSeries if axesScaleX == 'linear': plotRes = 'combine' elif axesScaleX == 'log10': plotRes = 'separate' elif axesScaleX == 'no uniform scale (sorted values as labels)': plotRes = 'separate' inputFile = open( ExternalTrackManager.extractFnFromGalaxyTN(file.split(':')), 'r') dataS = OrderedDict() dataS['xAxis'] = OrderedDict() dataS['yAxis'] = OrderedDict() i = 0 with inputFile as f: for x in f.readlines(): if i == 0: rowColumn = list(x.strip('\n').split('\t')) else: j = 0 for el in list(x.strip('\n').split('\t')): # if columnX[rowColumn[j]] == 'True': # if not rowColumn[j] in dataS['xAxis']: # dataS['xAxis'][rowColumn[j]] = [] # dataS['xAxis'][rowColumn[j]].append(el) if rowColumn[j] in columnX: if not rowColumn[j] in dataS['xAxis']: dataS['xAxis'][rowColumn[j]] = [] dataS['xAxis'][rowColumn[j]].append(el) if rowColumn[j] in columnY and columnY[ rowColumn[j]] == 'True': if not rowColumn[j] in dataS['yAxis']: dataS['yAxis'][rowColumn[j]] = [] dataS['yAxis'][rowColumn[j]].append(float(el)) j += 1 i += 1 inputFile.close() # this will be used just for x - values # keysX = dataS['xAxis'].keys() # if keysX == 1: # plotSeries = 'Single' # else: # plotSeries = 'Multi' #sorting categories values categoriesNumber = False sortedCat = None categories = None if columnX == 'line number': categories = None else: #if columnX['xAxis'] in columnY.keys(): if columnX in columnY.keys(): categoriesBefore = [float(v) for v in dataS['xAxis'][columnX]] if axesScaleX == 'log10': for cbN in range(0, len(categoriesBefore)): if categoriesBefore[cbN] != 0: categoriesBefore[cbN] = math.log( categoriesBefore[cbN], 10) sortedCat = sorted(range(len(categoriesBefore)), key=lambda k: categoriesBefore[k]) categories = [] for n in sortedCat: categories.append(categoriesBefore[n]) categoriesNumber = True else: categories = dataS['xAxis'][columnX] #dataS are sorted according to numerical values seriesName = [] data = [] for key, it in columnY.iteritems(): if it == 'True': dataPart = [] seriesName.append(key) dataPart = [] for x in dataS['yAxis'][key]: try: if axesScaleY == 'log10': if x != 0: dataPart.append(math.log(float(x), 10)) else: dataPart.append(0) else: dataPart.append(float(x)) except: dataPart.append(x) if sortedCat != None: dataPartTemp = [] for n in sortedCat: dataPartTemp.append(dataPart[n]) dataPart = dataPartTemp data.append(dataPart) label = '' if len(seriesName) != 0: label = '<b>{series.name}</b>: {point.x} {point.y}' else: label = '{point.x} {point.y}' # 'Column', 'Scatter', 'Heatmap' if axesScaleX == 'log10': xAxisTitle = str(columnX) + ' (' + str(axesScaleX) + ')' else: xAxisTitle = str(columnX) if axesScaleY == 'log10': yAxisTitle = str('values') + ' (' + str(axesScaleY) + ')' else: yAxisTitle = str('values') minFromList = min(min(d) for d in data) if minFromList > 0: minFromList = 0 #combain series with data if plotRes == 'combine': if categoriesNumber == True: newData = [] for d in data: newDataPart = [] for cN in range(0, len(categories)): newDataPart.append([categories[cN], d[cN]]) newData.append(newDataPart) data = newData categories = None vg = visualizationGraphs() res = '' if plotSeries == 'Single': if plotType == 'Scatter': res += vg.drawScatterChart(data, categories=categories, xAxisRotation=90, marginTop=30, xAxisTitle=xAxisTitle, yAxisTitle=yAxisTitle, height=500, seriesName=seriesName, label=label, minY=minFromList) if plotType == 'Column': res += vg.drawColumnChart(data, categories=categories, xAxisRotation=90, marginTop=30, xAxisTitle=xAxisTitle, yAxisTitle=yAxisTitle, height=500, seriesName=seriesName, label=label, minY=minFromList) elif plotSeries == 'Multi': if plotType == 'Scatter': for nrD in range(0, len(data)): if plotRes == 'combine': data[nrD] = [data[nrD]] res += vg.drawScatterChart( data[nrD], categories=categories, xAxisRotation=90, marginTop=30, xAxisTitle=xAxisTitle, yAxisTitle=yAxisTitle, height=500, seriesName=[seriesName[nrD]], label=label, minY=minFromList # titleText = 'Plot', ) if plotType == 'Column': res += vg.drawColumnCharts( data, categories=[categories for x in range(0, len(data))], xAxisRotation=90, marginTop=30, xAxisTitle=xAxisTitle, yAxisTitle=yAxisTitle, height=500, seriesName=[[seriesName[elD]] for elD in range(0, len(data))], label=label, minY=minFromList # titleText = 'Plot', ) htmlCore = HtmlCore() htmlCore.begin() htmlCore.divBegin(divId='results-page') htmlCore.divBegin(divClass='results-section') htmlCore.line(res) htmlCore.divEnd() htmlCore.divEnd() htmlCore.end() print htmlCore
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. ''' cls._setDebugModeIfSelected(choices) genome = choices.genome queryGSuite = getGSuiteFromGalaxyTN(choices.queryGSuite) refGSuite = getGSuiteFromGalaxyTN(choices.refGSuite) if choices.similarityFunc: similarityStatClassNameKey = choices.similarityFunc else: similarityStatClassNameKey = GSuiteStatUtils.T5_RATIO_OF_OBSERVED_TO_EXPECTED_OVERLAP isPointsVsSegments, pointsGSuite, segGSuite = cls.isPointsVsSegmentsAnalysis(queryGSuite, refGSuite) regSpec, binSpec = UserBinMixin.getRegsAndBinsSpec(choices) analysisBins = GalaxyInterface._getUserBinSource(regSpec, binSpec, genome=genome) queryTrackList = [Track(x.trackName, x.title) for x in queryGSuite.allTracks()] refTrackList = [Track(x.trackName, x.title) for x in refGSuite.allTracks()] queryTrackTitles = CommonConstants.TRACK_TITLES_SEPARATOR.join( [quote(x.title, safe='') for x in queryGSuite.allTracks()]) refTrackTitles = CommonConstants.TRACK_TITLES_SEPARATOR.join( [quote(x.title, safe='') for x in refGSuite.allTracks()]) analysisSpec = AnalysisSpec(GSuiteVsGSuiteWrapperStat) analysisSpec.addParameter('queryTracksNum', str(len(queryTrackList))) analysisSpec.addParameter('refTracksNum', str(len(refTrackList))) analysisSpec.addParameter('queryTrackTitleList', queryTrackTitles) analysisSpec.addParameter('refTrackTitleList', refTrackTitles) analysisSpec.addParameter('similarityStatClassName', GSuiteStatUtils.PAIRWISE_STAT_LABEL_TO_CLASS_MAPPING[similarityStatClassNameKey]) if choices.removeZeroRow: analysisSpec.addParameter('removeZeroRow', choices.removeZeroRow) if choices.removeZeroCol: analysisSpec.addParameter('removeZeroColumn', choices.removeZeroCol) resultsObj = doAnalysis(analysisSpec, analysisBins, queryTrackList + refTrackList) results = resultsObj.getGlobalResult() # baseDir = GalaxyRunSpecificFile([RAW_OVERLAP_TABLE_RESULT_KEY], galaxyFn).getDiskPath() # rawOverlapHeatmapPresenter = HeatmapFromDictOfDictsPresenter(resultsObj, baseDir, # 'Overlapping base-pair of tracks from the two suites', # printDimensions=False) rawOverlapTableData = results[RAW_OVERLAP_TABLE_RESULT_KEY] maxRawOverlap, maxROt1, maxROt2 = rawOverlapTableData.getMaxElement() similarityScoreTableData = results[SIMILARITY_SCORE_TABLE_RESULT_KEY] maxSimScore, maxSSt1, maxSSt2 = similarityScoreTableData.getMaxElement() baseDir = GalaxyRunSpecificFile([], galaxyFn=galaxyFn).getDiskPath() heatmapPresenter = HeatmapFromTableDataPresenter(resultsObj, baseDir=baseDir, header='Overlapping base-pairs between the tracks of the two suites', printDimensions=False) tablePresenter = MatrixGlobalValueFromTableDataPresenter(resultsObj, baseDir=baseDir, header='Table of overlapping base-pairs between the tracks of the two suites') core = HtmlCore() core.begin() core.divBegin(divId='results-page') core.divBegin(divId='svs-res-main-div', divClass='svs-res-main') core.divBegin(divId='raw-overlap-div', divClass='results-section') core.divBegin(divId='raw-overlap-table', divClass='svs-table-div') core.header('Base-pair overlaps between the tracks of the two GSuites') core.paragraph("""From the tracks in the two GSuites the highest base-pair overlap <b>(%s bps)</b> is observed for the pair of <b>'%s'</b> and <b>'%s'</b>.""" % (maxRawOverlap, maxROt1, maxROt2)) core.divBegin(divId='raw-table-result', divClass='result-div') core.divBegin(divId='raw-table-result', divClass='result-div-left') core.line('''Follow the links to view the results in an HTML table or raw tabular form:''') core.divEnd() core.divBegin(divId='raw-table-result', divClass='result-div-right') core.line(tablePresenter.getReference(RAW_OVERLAP_TABLE_RESULT_KEY)) core.divEnd()#rawoverlap table core.divEnd() core.divEnd() core.divBegin(divId='raw-overlap-heatmap', divClass='svs-heatmap-div') try: core.header('Heatmap of base-pair overlaps') core.divBegin(divId='raw-table-result', divClass='result-div-heatmap') core.divBegin(divId='raw-table-result', divClass='result-div-left') core.line('''Follow the links to view the heatmap in the desired format:''') core.divEnd() core.divBegin(divId='raw-table-result', divClass='result-div-right') core.line(heatmapPresenter.getReference(RAW_OVERLAP_TABLE_RESULT_KEY)) core.divEnd() core.divEnd() except: core.line('Heatmap for the base-pair overlaps could not be created.') core.divEnd() core.divEnd() core.divEnd()#rawoverlap heatmap core.divEnd()#rawoverlap core.divBegin(divId='sim-score-div', divClass='results-section') core.divBegin(divId='sim-score-table', divClass='svs-table-div') core.header('Similarity score between the tracks of the two GSuites measured by %s' % choices.similarityFunc) core.paragraph("""From the tracks in the two GSuites the highest similarity score <b>(%s)</b> is observed for the pair of <b>'%s'</b> and <b>'%s'</b>.""" % (maxSimScore, maxSSt1, maxSSt2)) core.divBegin(divId='raw-table-result', divClass='result-div') core.divBegin(divId='raw-table-result', divClass='result-div-left') core.line("""Follow the links to view the results in an HTML table or raw tabular form:""") core.divEnd() core.divBegin(divId='raw-table-result', divClass='result-div-right') core.line(tablePresenter.getReference(SIMILARITY_SCORE_TABLE_RESULT_KEY)) core.divEnd() core.divEnd() core.divEnd()#simscore table core.divBegin(divId='sim-score-heatmap', divClass='svs-heatmap-div') try: core.header('Heatmap of similarity scores') core.divBegin(divId='raw-table-result', divClass='result-div-heatmap') core.divBegin(divId='raw-table-result', divClass='result-div-left') core.line('''Follow the links to view the heatmap in the desired format:''') core.divEnd() core.divBegin(divId='raw-table-result', divClass='result-div-right') core.line(heatmapPresenter.getReference(SIMILARITY_SCORE_TABLE_RESULT_KEY)) core.divEnd() core.divEnd() except: core.line('Heatmap for the similarity score could not be created.') core.divEnd() core.divEnd() core.divEnd()#simscore heatmap core.divEnd()#simscore core.divEnd()#results # core.paragraph( # '''Table displaying the number of base-pairs overlapping between the tracks in the two suites:''') # core.tableFromDictOfDicts(rawOverlapTableData, firstColName='Track title') # # core.paragraph(rawOverlapHeatmapPresenter.getReference(resDictKey=RAW_OVERLAP_TABLE_RESULT_KEY)) # core.paragraph( # '''Table displaying the similarity score for the tracks in the two suites as measured by %s:''' % similarityStatClassNameKey) # core.tableFromDictOfDicts(similarityScoreTableData, firstColName='Track title') # core.divEnd() core.end() print str(core)
def getReference(self, resDictKey): return str(HtmlCore().link('HTML', self._getRelativeURL(self._htmlFns[resDictKey]))) + \ ' \ ' + \ str(HtmlCore().link('Raw text', self._getRelativeURL(self._rawFns[resDictKey])))
def execute(cls, choices, galaxyFn=None, username=''): path = str(URL_PREFIX) dataset = choices.dataset genome = choices.genome text = choices.newtrack secondDataset = choices.newdataset inputFile = open(ExternalTrackManager.extractFnFromGalaxyTN(dataset), 'r') with inputFile as f: data = [x for x in f.readlines()] silenceRWarnings() binSourceParam = '*' regSourceParam = '*' trackNamePrep = cls.preprocessTrack(genome, dataset) if text == 'No': figUrl = '' if (len(data) > 30000): core = HtmlCore() core.styleInfoBegin(styleClass='debug') figImage = GalaxyRunSpecificFile(['VizTrackOnGenome.png'], galaxyFn) analysisDef = ' [normalizeRows=%s] [centerRows=%s] -> RawVisualizationDataStat' res = GalaxyInterface.runManual([trackNamePrep], analysisDef, regSourceParam, binSourceParam, genome, username=username, printResults=False, printHtmlWarningMsgs=False) core.styleInfoEnd() core.line('') core.tableHeader(None) rScript = VisualizeTrackPresenceOnGenome.customRExecution( res, figImage.getDiskPath(ensurePath=True), '') figUrl = figImage.getURL() print GalaxyInterface.getHtmlEndForRuns() binSourceParam = '10m' regSourceParam = '*' cls.resultPrintGeneric(genome, binSourceParam, regSourceParam, figUrl, path, trackNamePrep) else: if isinstance(trackNamePrep[0], (list, )): numTracks = len(trackNamePrep[0]) firstTrack = cls.prepareTracknameForURL(trackNamePrep[0]) trackTitle = json.dumps(trackNamePrep[1]) cls.resultPrintGSuite(genome, binSourceParam, regSourceParam, figUrl, path, firstTrack, trackTitle, numTracks) else: firstTrack = cls.prepareTracknameForURL(trackNamePrep) cls.resultPrintGeneric(genome, binSourceParam, regSourceParam, figUrl, path, firstTrack) else: trackName2 = cls.preprocessTrack(genome, secondDataset) firstTrack = cls.prepareTracknameForURL(trackNamePrep) secondTrack = cls.prepareTracknameForURL(trackName2) cls.resultPrintOverlap(genome, binSourceParam, regSourceParam, path, firstTrack, secondTrack)
def getToolDescription(): return str(HtmlCore().paragraph(''' This tool creates a BED file with the segments corresponding to particular genes. Just paste a list of ENSEMBL IDs in the box, and click Execute.</p> '''))
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. ''' #print 'Executing...' HtmlCore().begin() core = HtmlCore() histChoices = choices[0] chosenResDictKey = choices[2] #this box needs to find relevant resDictKeys probably.. or could be a simple string input.. if choices[3] == 'Global results': useGlobal = True elif choices[3] == 'Local results': useGlobal = False else: raise lineWrapping = int(choices[4]) if choices[4] != '' else None if choices[5] == 'No': imputeNAs = False elif choices[5] == 'Yes (put in NA for missing results)': imputeNAs = True else: raise rowLabels = choices[6].split('|') if choices[6]!='' else None #print 'Use global results: ',useGlobal #print 'Linewrapping: ', lineWrapping #print 'Results dict key: ', chosenResDictKey resultsLists, historyNames = cls._getResultsLists(histChoices) resDictKeys, localKeys = cls._getResDictAndLocalKeys(resultsLists, imputeNAs) #print resultsLists from collections import defaultdict matrix = defaultdict(dict) for i,resultList in enumerate(resultsLists): #print 'Num results in history element: ', len(resultList) for j,oneResult in enumerate(resultList): if not (imputeNAs and len(oneResult.getResDictKeys())==0): assert set(oneResult.getResDictKeys()) == set(resDictKeys), (oneResult.getResDictKeys(), resDictKeys, [x.getResDictKeys() for x in resultList]) #print oneResult.keys(), localKeys #assert oneResult.keys() == localKeys colName = historyNames[i] + '-%05i' % j# if j>0 else '' if useGlobal: try: matrix['Global result'][colName] = oneResult.getGlobalResult()[chosenResDictKey] except: if imputeNAs: import numpy matrix['Global result'][colName] = numpy.nan else: raise else: for localKey in oneResult: matrix[localKey][colName] = oneResult[localKey][chosenResDictKey] #temporarily turned off.. #if chosenResDictKey=='P-value': # from proto.RSetup import r # origItems = matrix['Global result'].items() # matrix['FDR'] = dict(zip([x[0] for x in origItems], r('p.adjust')([x[1] for x in origItems],'BH') )) seedRegion = matrix.items()[0] sortedColNames = sorted(seedRegion[1].keys()) for regEntry, matVal in matrix.items(): assert sorted(matVal.keys()) == sortedColNames, 'Incompatible resultKeys, found both %s and %s, for region entries %s and %s.' % (seedRegion[1].keys(), matVal.keys(), seedRegion[0], regEntry ) #HTML VERSION #core.tableHeader([' ']+sortedColNames[:lineWrapping]) #for localKey in matrix: # if lineWrapping is None: # curRowLabel = rowLabels.pop(0) if rowLabels is not None else str(localKey) # core.tableLine([curRowLabel]+[str(matrix[localKey].get(historyName)) for historyName in sortedColNames]) # else: # numCols = len(sortedColNames) # for rowNum in range(numCols/lineWrapping): # curRowLabel = rowLabels.pop(0) if rowLabels is not None else str(localKey) # colSubset = sortedColNames[rowNum*lineWrapping:(rowNum+1)*lineWrapping] # core.tableLine([curRowLabel]+[str(matrix[localKey].get(historyName)) for historyName in colSubset]) #core.tableFooter() #core.end() #print core #TABULAR VERSION sortedResultNames = sortedColNames numResults = len(sortedResultNames) assert len(matrix.keys())==1, matrix.keys() localKey = matrix.keys()[0] if lineWrapping is None: lineWrapping = numResults numTabularCols = numResults/lineWrapping tabularColResults = [None] * numTabularCols for tabularColNum in range(numTabularCols): curRowLabel = rowLabels.pop(0) if rowLabels is not None else str(localKey) resultSubset = sortedResultNames[tabularColNum*lineWrapping:(tabularColNum+1)*lineWrapping] tabularColResults[tabularColNum] = [curRowLabel]+[str(matrix[localKey].get(historyName)) for historyName in resultSubset] assert len(set([len(x) for x in tabularColResults])) == 1 #all tabularCols have same length #else: # assert lineWrapping is None #not supported to split both across history elements and based on fixed number of results per column # tabularColResults = [None] * len(matrix.keys()) # for localKey in matrix: # curRowLabel = rowLabels.pop(0) if rowLabels is not None else str(localKey) # tabularColResults[tabularColNum] = [curRowLabel]+[str(matrix[localKey].get(historyName)) for historyName in sortedResultNames] tabularRowResults = zip(*tabularColResults) open(galaxyFn, 'w').writelines( ['\t'.join(rowResult)+'\n' for rowResult in tabularRowResults ])
def execute(choices, galaxyFn=None, username=''): #setupDebugModeAndLogging() from time import time startTime = time() print HtmlCore().begin() print '<pre>' genome = choices[0] #assert genome=='hg19' flankSize = choices[3] if choices[1] == 'Prepared catalogues': if choices[2] == 'GiulioNewGwas': gwasTnBase = 'Private:GK:NewGwasBase'.split(':') elif choices[2] == 'GiulioAllGwas': gwasTnBase = 'Private:GK:AllGiulioGwasSnpsAsOf9feb13'.split( ':') elif choices[2] == 'GiulioMay13Gwas': gwasTnBase = 'Private:GK:Gwas:GiulioMay13'.split(':') elif choices[2] == 'SmallTest': gwasTnBase = 'Private:GK:Gwas'.split(':') else: raise gwasTnBase += [flankSize] elif choices[1] == 'Custom track': gwasTnBase = choices[2].split(':') assert flankSize == 'SNPs' else: assert False, choices[1] referenceTrackSource = choices[4] normalization = choices[5] assert normalization == 'CoverageDepth' analysisType = choices[6] if analysisType == 'Enrichment': ResultClass = EnrichmentGwasResults elif analysisType == 'Testing': ResultClass = HypothesisTestingGwasResults nullmodelMapping = dict( zip([ 'Sample disease regions uniformly', 'Sample disease regions with preserved inter-region spacings', 'Sample disease regions with preserved distance to nearest exon' ], [ 'PermutedSegsAndSampledIntersegsTrack_', 'PermutedSegsAndIntersegsTrack_', 'SegsSampledByDistanceToReferenceTrack_,trackNameIntensity=Genes and gene subsets^Exons^Ensembl exons' ])) nullmodel = nullmodelMapping[choices[9]] assert nullmodel in [ 'PermutedSegsAndSampledIntersegsTrack_', 'PermutedSegsAndIntersegsTrack_', 'SegsSampledByDistanceToReferenceTrack_,trackNameIntensity=Genes and gene subsets^Exons^Ensembl exons' ] else: raise kernelType = choices[7] kernelParam = choices[8] if choices[10] == 'Include links to full underlying results': includeDetailedResults = True elif choices[10] == 'Only produce main result values': includeDetailedResults = False else: raise InvalidRunSpecException('Did not understand option: %s' % choices[12]) mcDepth = choices[11] if choices[12] == 'yes': includeLocalResults = True elif choices[12] == 'no': includeLocalResults = False else: raise InvalidRunSpecException('Did not understand option: %s' % choices[12]) if choices[15] == 'yes': useCache = True elif choices[15] == 'no': useCache = False else: raise InvalidRunSpecException('Did not understand option: %s' % choices[15]) if choices[16] == 'yes': printProgress = True elif choices[16] == 'no': printProgress = False else: raise InvalidRunSpecException('Did not understand option: %s' % choices[16]) from quick.application.GalaxyInterface import GalaxyInterface #print GalaxyInterface.getHtmlForToggles() #print GalaxyInterface.getHtmlBeginForRuns() #from quick.webtools.GwasAPI import getEnrichmentValues print 'Progress: ' #print 'base: ',gwasTnBase #print 'leaves: ',GalaxyInterface.getSubTrackNames(genome, gwasTnBase,deep=False, username=username) disRes = MultiGwasResults() from gold.application.HyperBrowserCLI import getSubTrackLeafTerms from quick.application.ProcTrackOptions import ProcTrackOptions #for gwasTrackLeaf in GalaxyInterface.getSubTrackNames(genome, gwasTnBase,deep=False, username=username): allDiseases = getSubTrackLeafTerms(genome, gwasTnBase, username=username) if len(allDiseases) == 0: assert ProcTrackOptions.isValidTrack( genome, gwasTnBase, GalaxyInterface.userHasFullAccess( username)), 'Genome: %s, TN: %s, Access: %s' % ( genome, gwasTnBase, GalaxyInterface.userHasFullAccess(username)) allDiseases = gwasTnBase[-1:] gwasTnBase = gwasTnBase[:-1] for disease in allDiseases: #print 'Leaf:',gwasTrackLeaf[0] #if not gwasTrackLeaf[0] in ['11 - Height.txt']: #if not disease in ['1 - Alzheimer.txt','10 - Graves.txt']:#['Malaria','UC']: # print 'IGNORING: ', gwasTrackLeaf[0] # continue #if gwasTrackLeaf in [[],None] or gwasTrackLeaf[0]=='-- All subtypes --': #continue #gwasTn = ':'.join(gwasTnBase + [gwasTrackLeaf[0]]) gwasTn = ':'.join(gwasTnBase + [disease]) #print 'Running API: ', "$getEnrichmentValues(%s, '%s', '%s')" % ([gwasTn], referenceTrackSource, normalization) #enrichmentsDict = getEnrichmentValues([gwasTn], referenceTrackSource, normalization)#, ['114 - Brain_Mid_Frontal_Lobe.txt','134 - Rectal_Smooth_Muscle.txt']) #assert len(enrichmentsDict.values())==1 #enrichments = enrichmentsDict.values()[0] #if gwasTrackLeaf[0] in ['Malaria','UC']: #print 'HERE IS WHAT I GOT: ',enrichmentsDict #print 'ENR: ',enrichments #print 'One: ', (enrichments.values()[0])['enrichment']['13 - CD4'].getGlobalResult() #assert 'enrichment' in (enrichments.values()[0]), (enrichments.values()[0]) #disRes[gwasTrackLeaf[0]] = (enrichments.values()[0])['enrichment'] #disRes[gwasTrackLeaf[0]] = (enrichments.values()[0]) #disease = gwasTrackLeaf[0] #disRes[disease] = [x.getGlobalResult() for x in enrichments] #print 'DISres: ', disRes[gwasTrackLeaf[0]] #from quick.util.CommonFunctions import extractIdFromGalaxyFn res = ResultClass(gwasId=disease, verbose=True, galaxyFn=galaxyFn) #referenceSubTypes = enrichments.keys() #referenceSubTypes = [x[0] for x in GalaxyInterface.getSubTrackNames(genome, 'Private:GK:Psych:DHSs'.split(':'), deep=False, username=username) if not x[0] == '-- All subtypes --'] if referenceTrackSource == 'H3K4me3': refTrackBase = 'Private:GK:Psych:H3K4me3' refTrackCoverageFunction = 'Private^GK^Psych^H3K4me3CoverageTrack' elif referenceTrackSource == 'DHS': refTrackBase = 'Private:GK:Psych:DHSs' refTrackCoverageFunction = 'Private^GK^Psych^DHSCoverageTrack' elif referenceTrackSource == 'Chromatin state 1-AP': refTrackBase = 'Private:Anders:Chromatin State Segmentation:1_Active_Promoter' refTrackCoverageFunction = 'Private^GWAS^Chromatin^CoverageFunctionTracks^1_Active_PromoterV2' elif referenceTrackSource == 'Chromatin state 4-SE': refTrackBase = 'Private:Anders:Chromatin State Segmentation:4_Strong_Enhancer' refTrackCoverageFunction = 'Private^GWAS^Chromatin^CoverageFunctionTracks^4_Strong_Enhancer' elif referenceTrackSource == 'Chromatin state 5-SE': refTrackBase = 'Private:Anders:Chromatin State Segmentation:5_Strong_Enhancer' refTrackCoverageFunction = 'Private^GWAS^Chromatin^CoverageFunctionTracks^5_Strong_Enhancer' else: raise refTrackSelectType = choices[13] allReferenceTracks = [ x[0] for x in GalaxyInterface.getSubTrackNames( genome, refTrackBase.split(':'), deep=False, username=username) if not x[0] == '-- All subtypes --' ] if refTrackSelectType == 'Use all reference tracks': referenceSubTypes = allReferenceTracks elif refTrackSelectType == 'Select single reference track': referenceSubTypes = [choices[14]] assert referenceSubTypes[0] in allReferenceTracks elif refTrackSelectType == 'Select a range among all reference tracks': try: firstRefTrack, lastRefTrack = choices[14].split('-') referenceSubTypes = allReferenceTracks[ int(firstRefTrack):int(lastRefTrack) + 1] print 'Analyzing %s among a total of %s reference tracks' % ( choices[14], len(allReferenceTracks)) except Exception: print 'Range format should be e.g. "15-18".' raise else: raise for referenceSubType in referenceSubTypes: #if not referenceSubType in ['107 - Adult_Kidney.txt','106 - Adipose_Nuclei.txt']: # #print 'IGNORING: ',referenceSubType # continue # if analysisType == 'Enrichment': res[referenceSubType] = directGetEnrichment( gwasTn, referenceSubType, refTrackBase, kernelType, kernelParam, useCache, printProgress) elif analysisType == 'Testing': res[referenceSubType] = directGetTestResults( gwasTn, referenceSubType, refTrackBase, kernelType, kernelParam, refTrackCoverageFunction, nullmodel, mcDepth, useCache, printProgress) else: raise #print disease, referenceSubType, res[referenceSubType] #print "ENR: ",enrichments #res[referenceSubType] = enrichments[referenceSubType] disRes[disease] = res #for disease in disRes: # print 'D FULL %s:' %disease, disRes[disease] # print 'D DICTS %s:'%disease, disRes[disease].getAllGlobalResultDicts() # print 'DISEASE %s:'%disease, disRes[disease].getAllGlobalResults() print 'Total run time (excluding figure generation): %i seconds.' % ( time() - startTime) print '</pre>' #print GalaxyInterface.getHtmlBeginForRuns() print '<h1>Results</h1>' if len(allDiseases) > 1: try: heatMapLink = disRes.getLinkToClusteredHeatmap( 'Heatmap', galaxyFn) print '<h3>Heatmap</h3>', heatMapLink #, '<br>' except: print '<p>Creation of heatmap failed</p>' tableOutput = disRes.getHtmlResultsTable(includeDetailedResults) print '<h3>Results table</h3>', tableOutput if choices[-1]: print '<h3>Prior coloring table</h3>' colorFn = ExternalTrackManager.extractFnFromGalaxyTN( choices[-1].split(':')) print disRes.getColoredSortedReferencesTable(colorFn) if includeLocalResults: print '<h3>Local results</h3>' print disRes.getLinksToAllLocalHtmlResultsTables(galaxyFn)
def execute(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. ''' # from gold.application.LogSetup import setupDebugModeAndLogging #setupDebugModeAndLogging() # targetTrackNames, targetTrackCollection, targetTrackGenome = getGSuiteDataFromGalaxyTN(choices.gSuiteFirst) # targetTracksDict = OrderedDict(zip(targetTrackNames, targetTrackCollection)) # refTrackNames, refTrackCollection, refTrackCollectionGenome = getGSuiteDataFromGalaxyTN(choices.gSuiteSecond) # refTracksDict = OrderedDict(zip(refTrackNames, refTrackCollection)) # targetGSuite = getGSuiteFromGalaxyTN(choices.gSuiteFirst) refGSuite = getGSuiteFromGalaxyTN(choices.gSuiteSecond) regSpec, binSpec = UserBinMixin.getRegsAndBinsSpec(choices) if choices.intraOverlap == TrackCollectionsAnalysis.MERGE_INTRA_OVERLAPS: analysisDef = 'dummy -> RawOverlapStat' else: analysisDef = 'dummy [withOverlaps=yes] -> RawOverlapAllowSingleTrackOverlapsStat' results = OrderedDict() # for targetTrackName, targetTrack in targetTracksDict.iteritems(): # for refTrackName, refTrack in refTracksDict.iteritems(): for targetTrack in targetGSuite.allTracks(): targetTrackName = targetTrack.title for refTrack in refGSuite.allTracks(): refTrackName = refTrack.title if targetTrack.trackName == refTrack.trackName: result = TrackCollectionsAnalysis.handleSameTrack(targetTrack.trackName, regSpec, binSpec, choices.genome, galaxyFn) else: result = GalaxyInterface.runManual([targetTrack.trackName, refTrack.trackName], analysisDef, regSpec, binSpec, choices.genome, galaxyFn, printRunDescription=False, printResults=False).getGlobalResult() if targetTrackName not in results : results[targetTrackName] = OrderedDict() results[targetTrackName][refTrackName] = result stat = choices.statistic statIndex = STAT_LIST_INDEX[stat] title = 'Screening track collections (' + stat + ')' processedResults = [] headerColumn = [] for targetTrackName in targetGSuite.allTrackTitles(): resultRowDict = processRawResults(results[targetTrackName]) resultColumn = [] headerColumn = [] for refTrackName, statList in resultRowDict.iteritems(): resultColumn.append(statList[statIndex]) headerColumn.append(refTrackName) processedResults.append(resultColumn) transposedProcessedResults = [list(x) for x in zip(*processedResults)] tableHeader = ['Track names'] + targetGSuite.allTrackTitles() htmlCore = HtmlCore() htmlCore.begin() htmlCore.header(title) htmlCore.divBegin('resultsDiv') htmlCore.tableHeader(tableHeader, sortable=True, tableId='resultsTable') for i, row in enumerate(transposedProcessedResults): line = [headerColumn[i]] + [strWithStdFormatting(x) for x in row] htmlCore.tableLine(line) htmlCore.tableFooter() htmlCore.divEnd() # #hicharts can't handle strings that contain ' or " as input for series names targetTrackNames = [x.replace('\'', '').replace('"','') for x in targetGSuite.allTrackTitles()] refTrackNames = [x.replace('\'', '').replace('"','') for x in refGSuite.allTrackTitles()] # # ''' # addColumnPlotToHtmlCore(htmlCore, targetTrackNames, refTrackNames, # stat, title + ' plot', # processedResults, xAxisRotation = -45, height=800) # ''' # ''' # addPlotToHtmlCore(htmlCore, targetTrackNames, refTrackNames, # stat, title + ' plot', # processedResults, xAxisRotation = -45, height=400) # ''' # from quick.webtools.restricted.visualization.visualizationGraphs import visualizationGraphs vg = visualizationGraphs() result = vg.drawColumnChart(processedResults, height=600, yAxisTitle=stat, categories=refTrackNames, xAxisRotation=90, seriesName=targetTrackNames, shared=False, titleText=title + ' plot', overMouseAxisX=True, overMouseLabelX = ' + this.value.substring(0, 10) +') htmlCore.line(result) #htmlCore.line(vg.visualizeResults(result, htmlCore)) htmlCore.hideToggle(styleClass='debug') htmlCore.end() print htmlCore
def validateAndReturnErrors(cls, choices): """ Should validate the selected input parameters. If the parameters are not valid, an error text explaining the problem should be returned. The GUI then shows this text to the user (if not empty) and greys out the execute button (even if the text is empty). If all parameters are valid, the method should return None, which enables the execute button. :param choices: Dict holding all current selections """ from quick.toolguide.controller.ToolGuide import ToolGuideController from quick.toolguide import ToolGuideConfig if not choices.queryTrack and not choices.gsuite: return ToolGuideController.getHtml(cls.toolId, [ToolGuideConfig.TRACK_INPUT, ToolGuideConfig.GSUITE_INPUT], choices.isBasic) if not choices.queryTrack: return ToolGuideController.getHtml(cls.toolId, [ToolGuideConfig.TRACK_INPUT], choices.isBasic) if not choices.gsuite: return ToolGuideController.getHtml(cls.toolId, [ToolGuideConfig.GSUITE_INPUT], choices.isBasic) errorString = cls._checkGSuiteFile(choices.gsuite) if errorString: return errorString errorString = cls._validateGenome(choices) if errorString: return errorString errorString = cls._checkTrack(choices, 'queryTrack', 'genome') if errorString: return errorString gsuite = getGSuiteFromGalaxyTN(choices.gsuite) errorString = cls._checkGSuiteRequirements \ (gsuite, cls.GSUITE_ALLOWED_FILE_FORMATS, cls.GSUITE_ALLOWED_LOCATIONS, cls.GSUITE_ALLOWED_TRACK_TYPES, cls.GSUITE_DISALLOWED_GENOMES) if errorString: return errorString errorString = cls._checkGSuiteTrackListSize(gsuite) if errorString: return errorString if choices.randStrat in [RAND_BY_UNIVERSE_TEXT]: errorString = cls._checkTrack(choices, 'intensityTrack', 'genome') if errorString: return errorString if choices.queryTrack and choices.intensityTrack: basicTFQuery = cls._getBasicTrackFormat(choices, 'queryTrack')[-1] basicTFIntensity = cls._getBasicTrackFormat(choices, 'intensityTrack')[-1] if not all(_ == 'points' for _ in [basicTFQuery, basicTFIntensity]): core = HtmlCore() core.paragraph('The selected randomization strategy requires the query and ' 'the universe track to both be of type "Points". One or both ' 'of these tracks have the incorrect track type.') core.descriptionLine('Current track type of query track', basicTFQuery) core.descriptionLine('Current track type of universe track', basicTFIntensity) core.paragraph('The only file formats (Galaxy datatypes) that ' 'support the "Points" track type is "gtrack" and "bed.points". ' 'To fix your input track(s), do as follows:') core.orderedList([ 'If you currently have a segment track (with segment lengths > 1), ' 'please convert it into points tracks by using the tool "Expand or ' 'contract points/segments" under the "Customize tracks" submenu.', 'If you currently have a "bed" file where all segments have ' 'length one, possibly as the result of step 1, you will need to ' 'change the Galaxy datatype to "point.bed". To do this, click the ' '"pencil" icon of the history element, select the "Datatypes" tab ' 'and select "point.bed".']) return str(core) errorString = cls.validateUserBins(choices) if errorString: return errorString