def annotatePos(insList, refGenome, outfileName, annotDir, printout): """loop through available annotations in annotDir/refgenome""" namefile = open(annotDir + "/" + refGenome + "/names.txt", 'r') outfile = open(outfileName, 'w') # set up each annotator (name, tabix file) present annDict = {} for nameline in namefile: (tname, tfile) = nameline.rstrip().split("\t") tfile = annotDir + "/" + refGenome + "/" + tfile annotator = annotate.annotator(tfile, tname, refGenome) annDict[tname] = annotator namefile.close() for ins in insList: outstring = str(ins) for annName, ann in annDict.iteritems(): bedline = "\t".join((ins.chr, ins.start, ins.end)) if ins.start > ins.end: bedline = "\t".join((ins.chr, ins.end, ins.start)) annList = ann.annotate(bedline, refGenome) annJoin = ",".join(annList) ins.annot.append(annJoin) if printout and ins.pseudo == 'False': # exclude overlaps with known pseudogenes print ins if ins.pseudo == 'False': outfile.write(str(ins) + "\n") outfile.close()
def annotatePos(insList,refGenome,annotDir,outfileName,printout): namefile = open(annotDir + "/" + refGenome + "/names.txt", 'r') outfile = open(outfileName, 'w') # set up each annotator (name, tabix file) present annDict = {} for nameline in namefile: (tname,tfile) = nameline.rstrip().split("\t") tfile = annotDir + "/" + refGenome + "/" + tfile annotator = annotate.annotator(tfile, tname, refGenome) annDict[tname] = annotator namefile.close() for ins in insList: outstring = str(ins) for annName,ann in annDict.iteritems(): bedline = "\t".join((ins.chr,ins.start,ins.end)) if ins.start > ins.end: bedline = "\t".join((ins.chr,ins.end,ins.start)) annList = ann.annotate(bedline,refGenome) annJoin = ",".join(annList) ins.annot.append(annJoin) if printout: print ins outfile.write(str(ins) + "\n") outfile.close()
def annotatePos(insList,refGenome,outfileName,annotDir,printout): """loop through available annotations in annotDir/refgenome""" namefile = open(annotDir + "/" + refGenome + "/names.txt", 'r') outfile = open(outfileName, 'w') # set up each annotator (name, tabix file) present annDict = {} for nameline in namefile: (tname,tfile) = nameline.rstrip().split("\t") tfile = annotDir + "/" + refGenome + "/" + tfile annotator = annotate.annotator(tfile, tname, refGenome) annDict[tname] = annotator namefile.close() for ins in insList: outstring = str(ins) for annName,ann in annDict.iteritems(): bedline = "\t".join((ins.chr,ins.start,ins.end)) if ins.start > ins.end: bedline = "\t".join((ins.chr,ins.end,ins.start)) annList = ann.annotate(bedline,refGenome) annJoin = ",".join(annList) ins.annot.append(annJoin) if printout and ins.pseudo == 'False': # exclude overlaps with known pseudogenes print ins if ins.pseudo == 'False': outfile.write(str(ins) + "\n") outfile.close()