def getOptionsBoxResults(cls, prevChoices): #if prevChoices.source.find('HyperBrowser') > -1: # return #if prevChoices.showResults in [None,'No']: # return if not prevChoices.source or prevChoices.transfer == 'Yes' or prevChoices.outputType != 'Select tracks manually': return gsm = TrackGlobalSearchModule(cls.useSqlite) if prevChoices.source.find('HyperBrowser') > -1: return gsm.getTrackFileList(prevChoices.search, prevChoices.subCategory, 'HyperBrowser') else: source = prevChoices.source.split('[')[0].strip() # # allFileTypes = [x.split('[')[0] for x,selected in prevChoices.filetype.iteritems()] # # fileTypes = [x.split('[')[0] for x,selected in prevChoices.filetype.iteritems() if selected] ##allDataTypes = [x.split('[')[0].strip() for x,selected in prevChoices.dataType.iteritems()] #dataTypes = [x.split('[')[0].strip() for x,selected in prevChoices.dataType.iteritems() if selected] dataTypes = [prevChoices.dataType.split('[')[0].strip()] ##Was made to speadup so that there will be no filetype comparisons, ##but deactivated for now since there is hardcoded filtering in ##prevChoices.fileType #if len(allFileTypes) == len(fileTypes): # fileTypes = [] #return '__rawStr__',gsm.getTrackFileList(prevChoices.search, prevChoices.subCategory,source,dataTypes) return gsm.getTrackFileList(prevChoices.search, prevChoices.subCategory, source, dataTypes)
def getOptionsBoxSource(cls, prevChoices): if prevChoices.subCategory in [None, '--Select--']: return gsm = TrackGlobalSearchModule(cls.useSqlite) items = gsm.getItems(prevChoices.search, prevChoices.subCategory) ##return [str(item) for item in items] sourceTupleList = gsm.getDataSources(items) sourceList = [] countAll = 0 for src, count in sourceTupleList: sourceList.append(src + ' [' + str(count) + ' files found]') countAll += count if len(sourceList) > 1: sourceList.insert( 0, 'All databases [' + str(countAll) + ' files found]') ##Asked to be removed by Sveinung. Commenting it out (maybe it will be reused later) # HBGsuite = quick.gsuite.GSuiteHbIntegration.getSubtracksAsGSuite('hg19', ['Sample data', 'Chromatin catalog', prevChoices.search, prevChoices.subCategory]) # if HBGsuite.numTracks() > 0: # sourceList.append('HyperBrowser['+str(HBGsuite.numTracks())+']') return sourceList
def getOptionsBoxOutputType(cls, prevChoices): #if prevChoices.source.find('HyperBrowser') > -1: # return if not prevChoices.source or prevChoices.transfer == 'Yes' or prevChoices.source.find('HyperBrowser') == -1 \ and not prevChoices.dataType: #and len([x for x,selected in prevChoices.dataType.iteritems() if selected]) == 0: return gsm = TrackGlobalSearchModule(cls.useSqlite) source = prevChoices.source.split('[')[0].strip() if prevChoices.source.find('HyperBrowser') > -1: #fileTypes = [] dataTypes = [] else: #fileTypes = [x.split('[')[0] for x,selected in prevChoices.filetype.iteritems() if selected] #dataTypes = [x.split('[')[0].strip() for x,selected in prevChoices.dataType.iteritems() if selected] dataTypes = [prevChoices.dataType.split('[')[0].strip()] count = gsm.getGSuite(prevChoices.search, prevChoices.subCategory, source, dataTypes, filterFileSuffix=True).numTracks() choicesList = [ 'Keep all tracks as selected above [' + str(count) + ']', 'Select tracks manually' ] ##if prevChoices.source.find('HyperBrowser') == -1: choicesList.extend( ['Select 10 random tracks', 'Select 50 random tracks']) # # if gsm.dataSourceExists(source): # # choicesList.append('Transfer selection to advanced mode for further fine-tuning') return choicesList
def getRedirectURL(cls, choices): gsm = TrackGlobalSearchModule(cls.useSqlite) sourceTool,attr_val_dict = gsm.getSourceToolURLParams(choices.search,\ choices.subCategory,\ choices.source.split('[')[0].strip()) return cls.createGenericGuiToolURL('hb_track_source_test_tool', sourceTool, attr_val_dict)
def getOptionsBoxResultsTable( cls, prevChoices): #To display results in HTML table if not prevChoices.source or prevChoices.transfer == 'Yes' or prevChoices.source.find('HyperBrowser') == -1 \ and not prevChoices.dataType: #and len([x for x,selected in prevChoices.dataType.iteritems() if selected]) == 0: return gsm = TrackGlobalSearchModule(cls.useSqlite) source = prevChoices.source.split('[')[0].strip() #dataTypes = [x.split('[')[0].strip() for x,selected in prevChoices.dataType.iteritems() if selected] dataTypes = [prevChoices.dataType.split('[')[0].strip()] rowDicts = None if prevChoices.outputType in [ None, 'select 10 random tracks', 'select 50 random tracks' ]: return elif 'all tracks' in prevChoices.outputType: rowDicts = gsm.getRowsDicts(prevChoices.search,prevChoices.subCategory,source,dataTypes,\ filterFileSuffix = True) elif prevChoices.outputType == 'Select tracks manually': rowDicts = gsm.getRowsDicts(prevChoices.search,prevChoices.subCategory,source,dataTypes,\ selectedFileIDs = prevChoices.results, filterFileSuffix = True) htmlTableDict = {} if rowDicts: for row in rowDicts: if 'url' in row: filename = row['url'].split('/')[-1] elif 'uri' in row: filename = row['uri'].split('/')[-1] elif '_url' in row: filename = row['_url'].split('/')[-1] else: filename = '<No filename>' rowList = [] for attr in cls.RESULT_COLS: if attr in row: rowList.append(unicode(row[attr])) htmlTableDict[filename] = rowList if len(htmlTableDict) == 0: return html = HtmlCore() html.tableFromDictionary(htmlTableDict, columnNames = ['File name'] + cls.RESULT_COLS_HEADER,\ tableId='t1', expandable=True) return '__rawstr__', unicode(html)
def getOptionsBoxDataType(cls, prevChoices): if not prevChoices.source or prevChoices.source.find( 'HyperBrowser') > -1 or prevChoices.transfer == 'Yes': return gsm = TrackGlobalSearchModule(cls.useSqlite) items = gsm.getItems(prevChoices.search, prevChoices.subCategory) source = prevChoices.source.split('[')[0].strip() datatypes = gsm.getDataTypes(items, source) countAll = 0 for dt, count in datatypes.iteritems(): countAll += count ##Change requested by Sveinung for simplicity #return OrderedDict([(dataType + ' ['+str(count)+']',True) for dataType,count in datatypes.iteritems()]) #return ['All data types ['+str(countAll)+' files found]'] + \ return [ dataType + ' [' + str(count) + ' files found]' for dataType, count in datatypes.iteritems() ]
def getOptionsBoxSubCategory(cls, prevChoices): if prevChoices.search == '--Select--': return gsm = TrackGlobalSearchModule(cls.useSqlite) return ['--Select--'] + gsm.getSubCategories(prevChoices.search)
def getOptionsBoxSearch(cls, prevChoices): gsm = TrackGlobalSearchModule(cls.useSqlite) return ['--Select--'] + gsm.getCategories()
def execute(cls, choices, galaxyFn=None, username=''): if not choices.source: return source = choices.source.split('[')[0].strip() fileTypes = [] gsm = TrackGlobalSearchModule(cls.useSqlite) desc = choices.subCategory if choices.source.find('HyperBrowser') == -1: #items = gsm.getItems(choices.search,choices.subCategory) # # allFileTypes = [x.split('[')[0] for x,selected in prevChoices.filetype.iteritems()] # # fileTypes = [x.split('[')[0] for x,selected in prevChoices.filetype.iteritems() if selected] ##allDataTypes = [x.split('[')[0].strip() for x,selected in choices.dataType.iteritems()] #dataTypes = [x.split('[')[0].strip() for x,selected in choices.dataType.iteritems() if selected] dataTypes = [choices.dataType.split('[')[0].strip()] ##Was made to speadup so that there will be no filetype comparisons, ##but deactivated for now since there is hardcoded filtering in ##prevChoices.fileType #if len(allFileTypes) == len(fileTypes): # fileTypes = [] if 'all tracks' in choices.outputType: remoteGSuite = gsm.getGSuite(choices.search, choices.subCategory, source, dataTypes, filterFileSuffix=True) elif choices.outputType == 'Select tracks manually': remoteGSuite = gsm.getGSuite(choices.search,choices.subCategory,source,dataTypes,\ filterFileSuffix = True,selectedFileIDs = choices.results) elif choices.outputType == 'Select 10 random tracks': remoteGSuite = gsm.getRandomGSuite(choices.search,choices.subCategory,source,dataTypes,\ filterFileSuffix = True,count = 10) elif choices.outputType == 'Select 50 random tracks': remoteGSuite = gsm.getRandomGSuite(choices.search,choices.subCategory,source,dataTypes,\ filterFileSuffix = True,count = 50) if choices.downloadAndPreprocess == 'Yes' and choices.source.find( 'HyperBrowser') == -1: trackCount = remoteGSuite.numTracks() progressViewer = \ ProgressViewer([('Download tracks', trackCount), ('Preprocess tracks', trackCount)], galaxyFn) #from gold.gsuite.GSuiteDownloader import GSuiteMultipleGalaxyFnDownloader #gSuiteDownloader = GSuiteMultipleGalaxyFnDownloader() #localGSuite, errorLocalGSuite = \ # gSuiteDownloader.visitAllGSuiteTracksAndReturnOutputAndErrorGSuites\ # (remoteGSuite, progressViewer, cls.extraGalaxyFn) from gold.gsuite.GSuiteDownloader import GSuiteSingleGalaxyFnDownloader from quick.gsuite.GSuiteHbIntegration import \ writeGSuiteHiddenTrackStorageHtml gSuiteDownloader = GSuiteSingleGalaxyFnDownloader() hiddenStorageFn = cls.extraGalaxyFn[getGSuiteHistoryOutputName( 'storage', desc)] localGSuite, errorLocalGSuite = \ gSuiteDownloader.visitAllGSuiteTracksAndReturnOutputAndErrorGSuites \ (remoteGSuite, progressViewer, hiddenStorageFn, []) writeGSuiteHiddenTrackStorageHtml(hiddenStorageFn) progressViewer.updateProgressObjectElementCount( 'Preprocess tracks', localGSuite.numTracks()) gSuitePreprocessor = GSuitePreprocessor() preProcessedGSuite, errorPreProcessGSuite = \ gSuitePreprocessor.visitAllGSuiteTracksAndReturnOutputAndErrorGSuites\ (localGSuite, progressViewer) #preProcessedGSuite, errorPreProcessGSuite = localGSuite.preProcessAllLocalTracksAndReturnOutputAndErrorGSuites(progressViewer) GSuiteComposer.composeToFile( remoteGSuite, cls.extraGalaxyFn[getGSuiteHistoryOutputName('remote', desc)]) GSuiteComposer.composeToFile( errorLocalGSuite, cls.extraGalaxyFn[getGSuiteHistoryOutputName( 'nodownload', desc)]) GSuiteComposer.composeToFile( localGSuite, cls.extraGalaxyFn[getGSuiteHistoryOutputName('primary', desc)]) GSuiteComposer.composeToFile( errorPreProcessGSuite, cls.extraGalaxyFn[getGSuiteHistoryOutputName( 'nopreprocessed', desc)]) GSuiteComposer.composeToFile( preProcessedGSuite, cls.extraGalaxyFn[getGSuiteHistoryOutputName( 'preprocessed', desc)]) else: GSuiteComposer.composeToFile(remoteGSuite, galaxyFn)