def _getUriForDownloadedAndUncompressedTrackPossiblyCached( self, gSuiteTrack, galaxyFn, uncomprSuffix, extraFileName=None): from gold.gsuite.GSuiteTrackCache import GSUITE_TRACK_CACHE cache = GSUITE_TRACK_CACHE if cache.isCached(gSuiteTrack): cachedUri = cache.getCachedGalaxyUri(gSuiteTrack) if os.path.exists(GSuiteTrack(cachedUri).path): return cache.getCachedGalaxyUri(gSuiteTrack) if extraFileName: from quick.application.ExternalTrackManager import ExternalTrackManager outGalaxyFn = ExternalTrackManager.createGalaxyFilesFn( galaxyFn, extraFileName) ensurePathExists(outGalaxyFn) if extraFileName.endswith('.' + uncomprSuffix): uri = GalaxyGSuiteTrack.generateURI( galaxyFn=galaxyFn, extraFileName=extraFileName) else: uri = GalaxyGSuiteTrack.generateURI( galaxyFn=galaxyFn, extraFileName=extraFileName, suffix=uncomprSuffix) else: outGalaxyFn = galaxyFn uri = GalaxyGSuiteTrack.generateURI(galaxyFn=outGalaxyFn, suffix=uncomprSuffix) uncompressorAndDownloader = GSuiteTrackUncompressorAndDownloader() uncompressorAndDownloader.visit(gSuiteTrack, outGalaxyFn) if cache.shouldBeCached(gSuiteTrack): cache.cache(gSuiteTrack, uri) return uri
def execute(cls, choices, galaxyFn=None, username=''): basisTrackNameAsList = choices.basisTrack.split(':') extractionOptions = dict( GalaxyInterface.getTrackExtractionOptions(choices.genome, basisTrackNameAsList)) extractionFormat = extractionOptions[ choices.extFormatLbl] if extractionOptions else None gsuite = getGSuiteFromGalaxyTN(choices.gsuite) outGSuite = GSuite() for gsTrack in gsuite.allTracks(): # outputTrackFn = cls.extraGalaxyFn[gsTrack.title] # print '<br>\n<br>\n output track filename: ', outputTrackFn # print 'path: ', gsTrack.path # print 'parsed uri: ', gsTrack._parsedUri newTrackFileName = gsTrack.title + '.' + extractionFormat outGalaxyFn = ExternalTrackManager.createGalaxyFilesFn( galaxyFn, newTrackFileName) ensurePathExists(outGalaxyFn) uri = GalaxyGSuiteTrack.generateURI(galaxyFn, extraFileName=newTrackFileName) GalaxyInterface.parseExtFormatAndExtractTrackManyBins( choices.genome, basisTrackNameAsList, gsTrack.suffix, gsTrack.path, True, choices.extFormatLbl, outGalaxyFn) outGSuite.addTrack( GSuiteTrack(uri, title=gsTrack.title, fileFormat=gsTrack.fileFormat, trackType=gsTrack.trackType, genome=choices.genome, attributes=gsTrack.attributes)) GSuiteComposer.composeToFile(outGSuite, galaxyFn)