def doSNPList(comparisons, comparison): stat, cut = comparisons.getSLStat(comparison) popInfos = list(comparisons.getSLPopsInfo(comparison)) SNPLists = MEGA.getSNPLists() SNPListNames = list(SNPLists.keys()) for name in SNPListNames: w = open("cmp.sl.%s.%s" % (name, comparison), "w") w.write("\t\t\t") popInfos = list(comparisons.getGLPopsInfo(comparison)) for popInfo in popInfos: w.write("\t%s" % (popInfo,)) w.write("\n") SNPs = SNPLists[name] winContentSNP = {} winContentGenes = {} winSpot = {} for i in range(len(SNPs)): winContentSNP.setdefault((SNPs[i][1], SNPs[i][2] - SNPs[i][2] % 200000), []).append(SNPs[i]) for popInfo in popInfos: popName = popInfo[0] if len(popInfo) > 1: suppPop = popInfo[1] else: suppPop = None md5, fName = comparisons.getGLFileName(popName, stat, cut, suppPop) f = open("%s/sets/%s/%s/%s" % (MEGA.cacheDB, args.karyo, md5, fName)) for l in f: toks = l.rstrip().split("\t") chro = int(toks[0]) pos = int(toks[1]) if (chro, pos) not in list(winContentSNP.keys()): continue if len(toks) > 4: windMarkers = toks[4].split(" ") else: windMarkers = [] winContentGenes[(chro, pos)] = windMarkers winSpot.setdefault((chro, pos), []).append(popName) for chro, pos in winSpot: w.write("%d\t%d\t%s\t%s" % ( chro, pos, " ".join([x[0] + " " + str(x[2]) for x in winContentSNP[chro, pos]]), " ".join(winContentGenes[chro, pos]))) for popInfo in popInfos: popName = popInfo[0] w.write("\t") if popName in winSpot[(chro, pos)]: w.write("X") w.write("\n") w.close()
print("<tr><td>") print("</td><td>".join(l.rstrip().split("\t"))) print("</td></tr>") print("</table>") print(web.linkFile(studyName, "cmp.pr.%s" % name, "(download)", isStudy=True, fType="text/plain")) print("<br>") print(web.linkFile(studyName, "cmp.p2.%s" % name, "Windows", isStudy=True, fType="text/plain")) elif study.comparisons.getType(name)=="Gene List": os.chdir(MEGA.cacheDB + "/studies/"+studyName) f = open("cmp.gl.%s" % name) print("<table>") for l in f: print("<tr><td>") print("</td><td>".join(l.rstrip().split("\t"))) print("</td></tr>") print("</table>") print(web.linkFile(studyName, "cmp.gl.%s" % name, "(download)", isStudy=True, fType="text/plain")) elif study.comparisons.getType(name)=="SNP List": os.chdir(MEGA.cacheDB + "/studies/"+studyName) snpLists = MEGA.getSNPLists() for lst in snpLists: f = open("cmp.sl.%s.%s" % (lst,name)) print(lst) print("<table border=1>") for l in f: print("<tr><td>") print("</td><td>".join(l.rstrip().split("\t"))) print("</td></tr>") print("</table>") print(web.linkFile(studyName, "cmp.sl.%s.%s" % (lst,name), "(download)", isStudy=True, fType="text/plain"))