def trackPrepare(self, inputTracks, genome) : #just filter out the -- All subtypes -- tag if it exists output = [] for track in inputTracks : if isinstance(track, basestring) : track = track.split(":") if track[-1] == "-- All subtypes --" : output.append(track[:-1]) else : output.append(track) output = GalaxyInterface._cleanUpTracks(output, genome, realPreProc=True) return output
def parseBatchLine(batchLine, genome, fullAccess): if batchLine[0] == '#' or batchLine.strip() == '': return from urllib import unquote #Split and check number of columns cols = [x for x in batchLine.strip().split(BATCH_COL_SEPARATOR)] if len(cols) != 6: results = Results(['N/A'], ['N/A'], 'N/A') #results.addResultComponent( 'Invalid',InvalidRunResultComponent('Error in batch specification. 6 columns are required, while '\ # + str(len(cols)) + ' are given.')) results.addError(InvalidRunSpecException('Error in batch specification. 6 columns are required, while '\ + str(len(cols)) + ' are given: ' + batchLine)) return results, None, None, None, None bc = BatchContents() bc.regSpec = cols[1] bc.binSpec = unquote(cols[2]) from quick.application.ExternalTrackManager import ExternalTrackManager if ExternalTrackManager.isGalaxyTrack(bc.binSpec.split(':')): bc.binSpec = ExternalTrackManager.extractFnFromGalaxyTN( bc.binSpec.split(':')) try: from quick.application.GalaxyInterface import GalaxyInterface bc.trackName1 = [unquote(x) for x in cols[3].split(':')] bc.trackName2 = [unquote(x) for x in cols[4].split(':')] bc.cleanedTrackName1, bc.cleanedTrackName2 = GalaxyInterface._cleanUpTracks( [bc.trackName1, bc.trackName2], genome, realPreProc=True) bc.cleanedTrackName1 = BatchRunner._inferTrackName( bc.cleanedTrackName1, genome, fullAccess) bc.cleanedTrackName2 = BatchRunner._inferTrackName( bc.cleanedTrackName2, genome, fullAccess) except (InvalidRunSpecException, IdenticalTrackNamesError), e: if DebugConfig.PASS_ON_BATCH_EXCEPTIONS: raise bc.errorResult = Results(['N/A'], ['N/A'], 'N/A') bc.errorResult.addError(e) return bc
def parseBatchLine(batchLine, genome, fullAccess): if batchLine[0] == '#' or batchLine.strip() == '': return from urllib import unquote # Split and check number of columns cols = [x for x in batchLine.strip().split(BATCH_COL_SEPARATOR)] if len(cols) != 6: results = Results(['N/A'], ['N/A'], 'N/A') results.addError(InvalidRunSpecException('Error in batch specification. 6 columns are required, while '\ + str(len(cols)) + ' are given: ' + batchLine)) return results, None, None, None, None bc = BatchContents() bc.regSpec = cols[1] bc.binSpec = unquote(cols[2]) from quick.application.ExternalTrackManager import ExternalTrackManager if ExternalTrackManager.isGalaxyTrack(bc.binSpec.split(':')): bc.binSpec = ExternalTrackManager.extractFnFromGalaxyTN(bc.binSpec.split(':')) bc.statClassName, bc.paramDict = BatchRunner._parseClassAndParams(cols[5]) bc.trackNames = [[unquote(x) for x in cols[i].split(':')] for i in [3, 4]] if 'trackNameIntensity' in bc.paramDict: bc.trackNames.append(convertTNstrToTNListFormat(bc.paramDict['trackNameIntensity'], doUnquoting=True)) from quick.application.GalaxyInterface import GalaxyInterface partlyCleanedTrackNames = GalaxyInterface._cleanUpTracks(bc.trackNames, genome, realPreProc=True) try: bc.cleanedTrackNames = BatchRunner._inferTrackNames(partlyCleanedTrackNames, genome, fullAccess) except (InvalidRunSpecException,IdenticalTrackNamesError), e: if DebugConfig.PASS_ON_BATCH_EXCEPTIONS: raise bc.errorResult = Results(['N/A'],['N/A'],'N/A') bc.errorResult.addError(e) return bc
def runJob(batchLine, genome, fullAccess): if batchLine[0] == '#' or batchLine.strip()=='': return from urllib import unquote #Split and check number of columns cols = [x for x in batchLine.strip().split(BATCH_COL_SEPARATOR)] if len(cols) != 6: results = Results(['N/A'],['N/A'],'N/A') #results.addResultComponent( 'Invalid',InvalidRunResultComponent('Error in batch specification. 6 columns are required, while '\ # + str(len(cols)) + ' are given.')) results.addError(InvalidRunSpecException('Error in batch specification. 6 columns are required, while '\ + str(len(cols)) + ' are given: ' + batchLine)) return results #print 'COL2: ',cols[2] cols[2] = unquote(cols[2]) #print 'COL2: ',cols[2] from quick.application.ExternalTrackManager import ExternalTrackManager if ExternalTrackManager.isGalaxyTrack(cols[2].split(':')): cols[2] = ExternalTrackManager.extractFnFromGalaxyTN(cols[2].split(':')) #print 'COL2: ',cols[2] try: from quick.application.GalaxyInterface import GalaxyInterface trackName1 = [unquote(x) for x in cols[3].split(':')] trackName2 = [unquote(x) for x in cols[4].split(':')] cleanedTrackName1, cleanedTrackName2 = GalaxyInterface._cleanUpTracks([trackName1, trackName2], genome, realPreProc=True) cleanedTrackName1 = BatchRunner._inferTrackName(':'.join(cleanedTrackName1), genome, fullAccess) cleanedTrackName2 = BatchRunner._inferTrackName(':'.join(cleanedTrackName2), genome, fullAccess) except (InvalidRunSpecException,IdenticalTrackNamesError), e: if DebugConfig.PASS_ON_BATCH_EXCEPTIONS: raise results = Results(['N/A'],['N/A'],'N/A') results.addError(e) return results
class BatchRunner(object): @staticmethod def runFromFn(batchFn, genome, fullAccess): return BatchRunner.runManyLines( [line for line in open(batchFn, genome, fullAccess)]) @staticmethod def runManyLines(batchLines, genome, fullAccess, useBatchId=True, galaxyFn=None, printProgress=True): #fixme: useBatchId is currently ignored! Do something with it if this was a meaningful name from a standard batch run.... resList = [] for line in batchLines: resList.append( BatchRunner.runJob(line, genome, fullAccess, galaxyFn=galaxyFn, printProgress=printProgress)) return resList @staticmethod def parseBatchLine(batchLine, genome, fullAccess): if batchLine[0] == '#' or batchLine.strip() == '': return from urllib import unquote #Split and check number of columns cols = [x for x in batchLine.strip().split(BATCH_COL_SEPARATOR)] if len(cols) != 6: results = Results(['N/A'], ['N/A'], 'N/A') #results.addResultComponent( 'Invalid',InvalidRunResultComponent('Error in batch specification. 6 columns are required, while '\ # + str(len(cols)) + ' are given.')) results.addError(InvalidRunSpecException('Error in batch specification. 6 columns are required, while '\ + str(len(cols)) + ' are given: ' + batchLine)) return results, None, None, None, None bc = BatchContents() bc.regSpec = cols[1] bc.binSpec = unquote(cols[2]) from quick.application.ExternalTrackManager import ExternalTrackManager if ExternalTrackManager.isGalaxyTrack(bc.binSpec.split(':')): bc.binSpec = ExternalTrackManager.extractFnFromGalaxyTN( bc.binSpec.split(':')) try: from quick.application.GalaxyInterface import GalaxyInterface bc.trackName1 = [unquote(x) for x in cols[3].split(':')] bc.trackName2 = [unquote(x) for x in cols[4].split(':')] bc.cleanedTrackName1, bc.cleanedTrackName2 = GalaxyInterface._cleanUpTracks( [bc.trackName1, bc.trackName2], genome, realPreProc=True) bc.cleanedTrackName1 = BatchRunner._inferTrackName( bc.cleanedTrackName1, genome, fullAccess) bc.cleanedTrackName2 = BatchRunner._inferTrackName( bc.cleanedTrackName2, genome, fullAccess) except (InvalidRunSpecException, IdenticalTrackNamesError), e: if DebugConfig.PASS_ON_BATCH_EXCEPTIONS: raise bc.errorResult = Results(['N/A'], ['N/A'], 'N/A') bc.errorResult.addError(e) return bc bc.errorResult, bc.userBinSource = BatchRunner._constructBins( bc.regSpec, bc.binSpec, genome, bc.cleanedTrackName1, bc.cleanedTrackName2) if bc.errorResult is not None: return bc bc.statClassName, bc.paramDict = BatchRunner._parseClassAndParams( cols[5]) bc.trackNameIntensity = [] if 'trackNameIntensity' in bc.paramDict: #fullRunParams['trackNameIntensity'] = paramDict['trackNameIntensity'].replace('_',' ').split(':') from quick.application.GalaxyInterface import GalaxyInterface import re #trackNameIntensity = re.split(':|\|', paramDict['trackNameIntensity']) bc.trackNameIntensity = convertTNstrToTNListFormat( bc.paramDict['trackNameIntensity'], doUnquoting=True) #print "HERE: ",trackNameIntensity bc.cleanedTrackNameIntensity = GalaxyInterface._cleanUpTracks( [bc.trackNameIntensity], genome, realPreProc=True)[0] bc.cleanedTrackNameIntensity = BatchRunner._inferTrackName( bc.cleanedTrackNameIntensity, genome, fullAccess) del bc.paramDict['trackNameIntensity'] return bc