def createGalaxyTnFromExternalTn(cls, externalTN): # Hack to support ConvertPrimaryGsuiteToLocalPathsTool from config.Config import EXT_RESULTS_PATH assert externalTN[0] == 'external' assert len(externalTN) == 5 resultsPathDirs = EXT_RESULTS_PATH.rstrip(os.path.sep).split( os.path.sep) assert resultsPathDirs[-1] == URL_PREFIX.strip('/') instance = externalTN[1] # Hack if instance == 'dev2': instance = 'developer' resultsPathDirs[-1] = instance extResultsFilesPath = os.path.sep.join(resultsPathDirs + ['files']) galaxyFn = protoFunctions.getGalaxyFnFromAnyDatasetId( externalTN[3], galaxyFilePath=extResultsFilesPath) filePath = protoFunctions.getGalaxyFilesFilename( galaxyFn, [externalTN[4]]) if not os.path.exists(filePath): raise ValueError( 'Original track file {} does not exist'.format(filePath)) fileSuffix = getFileSuffix(filePath) return cls.constructGalaxyTnFromSuitedFn(filePath, fileEnding=fileSuffix, name=externalTN[4])
def tableFromDictionary(self, dataDict, columnNames=None, sortable=True, tableId=None, expandable=False, visibleRows=6, presorted=None, **kwargs): """Render a table from data in dataDict. Each key in dataDict is a row title, each value is a list of values, each corresponding to the column given with columnNames. If presorted is set to a number and tableId != None and sortable == True, that column will be presorted (using a hacky solution using jquery. """ from proto import CommonFunctions dataDictOfLists = CommonFunctions.convertToDictOfLists(dataDict) if presorted is not None and presorted > -1: assert isinstance(presorted, int), 'presorted must be int' from quick.util import CommonFunctions dataDictOfLists = CommonFunctions.smartSortDictOfLists( dataDictOfLists, sortColumnIndex=presorted) tableClass = 'colored bordered' if expandable: tableClass += ' expandable' self.tableHeader(headerRow=columnNames, sortable=sortable, tableId=tableId, tableClass=tableClass, **kwargs) for key, val in dataDictOfLists.iteritems(): if isinstance(val, list): self.tableLine([key] + val, **kwargs) else: self.tableLine([key] + [val], **kwargs) self.tableFooter(expandable=expandable, tableId=tableId, numRows=len(dataDict), visibleRows=visibleRows, **kwargs) return self
def getGalaxyFnFromEncodedDatasetId(encodedId): return protoFunctions.getGalaxyFnFromEncodedDatasetId(encodedId)
def getEncodedDatasetIdFromPlainGalaxyId(plainId): return protoFunctions.getEncodedDatasetIdFromPlainGalaxyId(plainId)
def getEncodedDatasetIdFromGalaxyFn(cls, galaxyFn): return protoFunctions.getEncodedDatasetIdFromGalaxyFn(galaxyFn)
def extractIdFromGalaxyFn(fn): return protoFunctions.extractIdFromGalaxyFn(fn)
def extractFnFromGalaxyTN(cls, galaxyTN): return protoFunctions.extractFnFromDatasetInfo(galaxyTN)
def createGalaxyFilesFn(galaxyFn, filename): return protoFunctions.createGalaxyFilesFn(galaxyFn, filename)
def getGalaxyFilesFilename(cls, galaxyFn, id): """ id is the relative file hierarchy, encoded as a list of strings """ return protoFunctions.getGalaxyFilesFilename(galaxyFn, id)
def getGalaxyFilesDir(galaxyFn): return protoFunctions.getGalaxyFilesDir(galaxyFn)