def execute(cls, choices, galaxyFn=None, username=''): from quick.application.GalaxyInterface import GalaxyInterface fileformat = choices[9]; outputFile = open(galaxyFn, "w") if fileformat == "html": print GalaxyInterface.getHtmlBeginForRuns(galaxyFn) print GalaxyInterface.getHtmlForToggles(withRunDescription=False) t = calendar.timegm(time.gmtime()) htmlfile = GalaxyRunSpecificFile(["css", str(t)], galaxyFn); genome = choices[0] track1 = choices[1].split(":") track2 = choices[2].split(":") tn1 = ExternalTrackManager.getPreProcessedTrackFromGalaxyTN(genome, track1) tn2 = ExternalTrackManager.getPreProcessedTrackFromGalaxyTN(genome, track2) compare = choices[3] != "Count individual SNP-differences in window" if choices[4] == "Classical MDS": mds = 0; elif choices[4] == "SMACOF": mds = 1; else: mds = 2; windowSize = int(choices[5]) windowStep = int(choices[6]) mcTreshold = int(choices[7]) mcRuns = int(choices[8]) outputFile.write("#seqid\tstart\tscore\tp\n") if fileformat == "html": text = "#seqid\tstart\tscore\tp\n"; print "chrs:"+str(GenomeInfo.getChrList(genome)) reg = "*" bins = "*" analysisDef = "Dummy: dummy name ([wStep=%g] [wSize=%s] [func=%s] [mds=%s] [mcT=%s] [mcR=%s])-> CategoryClusterSeparationStat" % (windowStep, windowSize, compare, mds, mcTreshold, mcRuns) userBinSource = GalaxyInterface._getUserBinSource(reg, bins, genome) result = GalaxyInterface.runManual([tn1, tn2], analysisDef, reg, bins, genome, galaxyFn=galaxyFn) for key in result.getAllRegionKeys(): chrom = str(key).split(":")[0]; r = result[key]; if 'Result' not in r.keys(): print "skipping chr:", chrom, r; continue; r = r['Result']; scores = r[0]; stddev = r[1]; for i in range(len(scores)): if scores[i] != 0: pos = i*windowStep; if fileformat == "tabular": outputFile.write("%s\t%s\t%s\t%s\n" % (str(chrom), pos, str(scores[i]), str(stddev[i]))) else: text += "%s\t%s\t%s\t%s\n" % (str(chrom), pos, str(scores[i]), str(stddev[i])); if fileformat == "html": htmlfile.writeTextToFile(text); print htmlfile.getLink("Result file"); print GalaxyInterface.getHtmlEndForRuns() outputFile.close();
def execute(cls, choices, galaxyFn=None, username=""): from quick.application.GalaxyInterface import GalaxyInterface fileformat = choices[6] outputFile = open(galaxyFn, "w") if fileformat == "html": print GalaxyInterface.getHtmlBeginForRuns(galaxyFn) print GalaxyInterface.getHtmlForToggles(withRunDescription=False) t = calendar.timegm(time.gmtime()) htmlfile = GalaxyRunSpecificFile(["fet", str(t)], galaxyFn) genome = choices[0] track1 = choices[1].split(":") track2 = choices[2].split(":") tn1 = ExternalTrackManager.getPreProcessedTrackFromGalaxyTN(genome, track1) tn2 = ExternalTrackManager.getPreProcessedTrackFromGalaxyTN(genome, track2) windowSize = int(choices[3]) windowStep = int(choices[4]) percentile = float(choices[5]) # results = {} # TODO: why this? # tr = Track(tn1) # tr.addFormatReq(TrackFormatReq(dense=False, allowOverlaps=True)) outputFile.write("#seqid\tstart\tscore\tstddev\n") if fileformat == "html": text = "#seqid\tstart\tscore\tstddev\n" print "chrs:", str(GenomeInfo.getChrList(genome)) reg = "*" bins = "*" analysisDef = "Dummy: dummy name ([wStep=%g] [wSize=%g] [percentile=%g])-> FisherExactScoreStat" % ( windowStep, windowSize, percentile, ) userBinSource = GalaxyInterface._getUserBinSource(reg, bins, genome) result = GalaxyInterface.runManual([tn1, tn2], analysisDef, reg, bins, genome, galaxyFn=galaxyFn) for key in result.getAllRegionKeys(): chrom = str(key).split(":")[0] r = result[key] if "Result" not in r.keys(): print "skipping chr:", chrom, r continue r = r["Result"] scores = r[0] stddev = r[1] for i in range(len(scores)): if scores[i] != 0: pos = i * windowStep # if choices[5] == "html": # print "%s\t%s\t%s\t%s\n" % (str(chrom), pos, str(scores[i]), str(stddev[i])) if fileformat == "tabular": outputFile.write("%s\t%s\t%s\t%s\n" % (str(chrom), pos, str(scores[i]), str(stddev[i]))) else: text += "%s\t%s\t%s\t%s\n" % (str(chrom), pos, str(scores[i]), str(stddev[i])) if fileformat == "html": htmlfile.writeTextToFile(text) print htmlfile.getLink("Result file") print GalaxyInterface.getHtmlEndForRuns() outputFile.close()