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 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...' print GalaxyInterface.getHtmlBeginForRuns(galaxyFn) print GalaxyInterface.getHtmlForToggles(withRunDescription=False) genome = choices[1] flankSize = int(choices[3]) if choices[4] == cls.REGIONS_FROM_HISTORY: from quick.extra.tfbs.GeneTargetsOfTF import GeneTargetsOfRegions regionsTn = choices[5].split(':') GeneTargetsOfRegions.findGeneTargets(genome, regionsTn, flankSize, flankSize, galaxyFn) else: tfSource = choices[4] tfChoice = choices[5] from quick.extra.tfbs.GeneTargetsOfTF import GeneTargetsOfTF GeneTargetsOfTF.findGeneTargets(genome, tfSource, tfChoice, flankSize, flankSize, galaxyFn) print GalaxyInterface.getHtmlEndForRuns()
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 needed, can call _getStaticPath 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 'choices: ', choices genome = choices.genome queryTrackStr = choices.history if choices.trackSource == 'history' else choices.track queryTrack = queryTrackStr.split(':') geneSource = choices.geneSource upFlankSize = downFlankSize = int(choices.flank) print GalaxyInterface.getHtmlBeginForRuns(galaxyFn) print GalaxyInterface.getHtmlForToggles(withRunDescription=False) geneIntersection = GeneIntersection(genome, geneSource, queryTrack, galaxyFn) geneIntersection.expandReferenceTrack(upFlankSize, downFlankSize) expansionStr = ', after expansion,' if not ( upFlankSize == downFlankSize == 0) else '' print '<p>There are %i %s-genes that%s intersect elements from your query track (%s).</p>' % \ (geneIntersection.getNumberOfIntersectedBins(), geneSource, expansionStr, prettyPrintTrackName(queryTrack)) idFileNamer = geneIntersection.getGeneIdStaticFileWithContent() print '<p>', idFileNamer.getLoadToHistoryLink( 'Load to history the list', 'txt'), ' of all %s IDs intersecting query track.</p>' % ( geneSource) regFileNamer = geneIntersection.getIntersectedRegionsStaticFileWithContent( ) print '<p>', regFileNamer.getLoadToHistoryLink( 'Load to history a BED file', 'bed'), ' of all %s gene regions intersecting query track.</p>' % ( geneSource) print GalaxyInterface.getHtmlEndForRuns()
def execute(cls, choices, galaxyFn=None, username=''): cls._setDebugModeIfSelected(choices, galaxyFn) with stdout_redirector(open(galaxyFn, "w", 0)): core = HtmlCore() core.append(GalaxyInterface.getHtmlBeginForRuns(galaxyFn)) core.append( GalaxyInterface.getHtmlForToggles(withRunDescription=False)) core.styleInfoBegin(styleClass='debug') core.paragraph( 'GalaxyInterface.startPreProcessing({}, {}, {})'.format( choices.genome, choices.track, username)) print core if choices.parsingError == cls.MOVE_TO_PARSING_ERROR_CHOICE: finished = False while not finished: DebugConfig.PASS_ON_PREPROCESS_EXCEPTIONS = True try: GalaxyInterface.startPreProcessing( choices.genome, choices.track, username) finished = True except (PreprocessWarning, PreprocessError) as e: print e match = re.search("trackName=\"([^\"]+)\"", str(e)) if match: trackName = match.group(1).split(':') PlainMover().parseFiles(choices.genome, trackName, direction='std_to_error') else: # cls.DO_NOTHING_CHOICE GalaxyInterface.startPreProcessing(choices.genome, choices.track, username) core = HtmlCore() core.styleInfoEnd() core.script('done = true;') core.end() print core
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. ''' from quick.application.GalaxyInterface import GalaxyInterface from proto.hyperbrowser.HtmlCore import HtmlCore print GalaxyInterface.getHtmlBeginForRuns(galaxyFn) print GalaxyInterface.getHtmlForToggles(withRunDescription=False) print str(HtmlCore().styleInfoBegin(styleClass='debug')) from quick.application.ExternalTrackManager import ExternalTrackManager datasetId = ExternalTrackManager.extractIdFromGalaxyFn(ExternalTrackManager.extractFnFromGalaxyTN(choices[0]))[1] #print datasetId #print choices ##batchid = index for kjoering i batch. Ikke-batch-kjoering: 0 #batchid = 0 ##mapId = Definer hva slags type innhold i Google map-bokser (naar du trykker). Innholdet er definert (hardkodet) i GoogleMapsInterface.py: getHtmlText() og getClusterHtmlText() ##Eks: encode_tf_vs_tf if choices[1] != 'make new map id': mapId = choices[1] else: mapId = choices[2] from quick.application.ExternalTrackManager import ExternalTrackManager histHtml = open(ExternalTrackManager.extractFnFromGalaxyTN(choices[0].split(':'))).read() #rowTrackName = histHtml.split('<h3>TRACK 1</h3>')[-1].split('</b>')[1].split('\n')[0].strip()#.split(':') #colTrackName = histHtml.split('<h3>TRACK 2</h3>')[-1].split('</b>')[1].split('\n')[0].strip()#.split(':') from quick.application.GalaxyInterface import GalaxyInterface batchLine = histHtml.split('<h3>CORRESPONDING BATCH COMMAND LINE</h3>')[-1].split('<p>')[1].split('/p')[0].strip() genome = histHtml.split('<h3>GENOME</h3>')[-1].split('name:</b>')[1].split('<')[0].strip() fullAccess = GalaxyInterface.userHasFullAccess(username) from quick.batch.BatchRunner import BatchRunner batchContents = BatchRunner.parseBatchLine(batchLine, genome, fullAccess) rowTrackName = ':'.join(batchContents.cleanedTrackName1) colTrackName = ':'.join(batchContents.cleanedTrackName2) from quick.extra.CreateGoogleMapType import createMapType createMapType(mapId, genome, rowTrackName, colTrackName, 'None', 'None', 'None') from config.Config import HB_SOURCE_CODE_BASE_DIR GMapInterfaceFn = HB_SOURCE_CODE_BASE_DIR+'/quick/extra/GoogleMapsInterface.py' GMapInterfaceContent = open(GMapInterfaceFn).read() replaceStr = "'%s', 'encode_gwas_vs_dhs'" % mapId GMapInterfaceContent = GMapInterfaceContent.replace("'encode_gwas_vs_dhs'", replaceStr) open(GMapInterfaceFn,'w').write(GMapInterfaceContent) #title = navn paa Regulomet slik brukeren ser det, Eks: "ENCODE test, TFs vs TFs" title = choices[3] ##name = navn paa katalog for google map: Eks: encode_test_tf_vs_tf name = choices[4] from quick.extra.CreateGoogleMap import GoogleMapCreator from quick.extra.GoogleMapsInterface import Map onMedSeqProd = False #batchid creator = GoogleMapCreator(name, datasetId, mapId, genome=genome) creator.tile(onMedSeqProd) creator.copyResultFiles() creator.createResultShelves() creator.createIndexFile(title, genome) creator.fixPermissions() print str(HtmlCore().styleInfoEnd()) map = Map(name) row = [] row.append( str(HtmlCore().link(map.getPrettyName(), map.getUrl())) ) row.append( str(HtmlCore().link('Run description', map.getRunDescriptionUrl())) ) row.append( str(HtmlCore().link('Counts', map.getCountUrl())) ) row.append( str(HtmlCore().link('Effect size', map.getEffectSizeUrl())) ) row.append( str(HtmlCore().link('P-values', map.getPvalUrl())) ) core = HtmlCore() core.tableHeader(None) core.tableLine(row) core.tableFooter() print core print GalaxyInterface.getHtmlEndForRuns()
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. ''' genome = choices[0] regSpec = '__chrs__' binSpec = '*' if choices[6] == 'Chromosome arms': regSpec = '__chrArms__' elif choices[6] == 'Track from history...': #put in history bins support here #print choices[4:] regSpec = ExternalTrackManager.extractFileSuffixFromGalaxyTN(choices[7].split(':')) binSpec = ExternalTrackManager.extractFnFromGalaxyTN(choices[7].split(':')) #print 'regSpec, binSpec,', regSpec, binSpec lineList, counter, tooManyBins = [], 0, False for line in open(binSpec): if line.strip() !='': if counter == cls.MAX_NUM_ROWS: tooManyBins = True break lineList.append(line) counter+= 1 if line.strip()[0] !='#' else 0 if tooManyBins: newHist = GalaxyRunSpecificFile(['newHistFile.%s' % regSpec], galaxyFn) binSpec = newHist.getDiskPath(ensurePath=True) open(binSpec, 'w').write(''.join(lineList)) print GalaxyInterface.getHtmlBeginForRuns(galaxyFn) print GalaxyInterface.getHtmlForToggles(withRunDescription=False) core = HtmlCore() core.styleInfoBegin(styleClass='debug') figImage = GalaxyRunSpecificFile(['VizTrackOnGenome.png'], galaxyFn) #StaticImage(['VizTrackOnGenome.png']) analysisDef = ' [normalizeRows=%s] [centerRows=%s] -> RawVisualizationDataStat' % \ (choices[4] == 'Scale to same size', choices[5] == 'Center') if choices[1] == 'HyperBrowser repository': trackName = choices[2].split(':') else: trackName = ExternalTrackManager.getPreProcessedTrackFromGalaxyTN(genome, choices[3].split(':')) res = GalaxyInterface.runManual([trackName], analysisDef, regSpec, binSpec, genome, username=username, printResults=False, printHtmlWarningMsgs=False) core.styleInfoEnd() core.line('') core.tableHeader(None) #visPresenter = RawVisualizationPresenter(res, galaxyFn,'')#os.path.split()[0] #htmlStreng = visPresenter.getReference('Result', fullImage=True) rScript = cls.customRExecution(res, figImage.getDiskPath(ensurePath=True), '') figUrl = figImage.getURL() figLinkText ='<img src="%s" alt="Figure" height="%i" width="800"/>' % (figUrl, 20 *min(cls.MAX_NUM_ROWS, len(res))) core.tableLine([figImage.getLink(figLinkText)]) rScriptGalaxyFile = GalaxyRunSpecificFile(['RScript.R'], galaxyFn) with open(rScriptGalaxyFile.getDiskPath(ensurePath=True), 'w') as rScriptFile: rScriptFile.write(rScript) core.tableLine([rScriptGalaxyFile.getLink('R script')]) core.tableFooter() print core print GalaxyInterface.getHtmlEndForRuns()