def main(options): hdr = [] hdrlen = 0 count = 0 try: fh = open(options.chrommap) chrom_map = load_chrom_map(fh) except: print "Unable to open", options.chrommap exit() dbsnpfile = Dbsnpfile() dbsnpfile.set_tabix_file(options.dbsnpfile) for line in sys.stdin: count += 1 line = line.strip() if (line.startswith('#')): print line else: vcfr = VCFrecord(line) posn = vcfr.get_posn_as_int() try: dbsnprecs = dbsnpfile.get_dbsnp_file_record( options.dbsnpfile, chrom_map[options.chrom], posn) except: print "Chromosome not found in map", options.chrom exit() if len(dbsnprecs) > 0: vcfr.set_varid(dbsnpfile.get_rsid(dbsnprecs[0])) else: logging.info("NOT FOUND for %s at %d" % (options.chrom, posn)) print vcfr.get_record() return count
def main(options): hdr = [] hdrlen = 0 count = 0 try: fh = open(options.chrommap) chrom_map = load_chrom_map(fh) except: print "Unable to open", options.chrommap exit() for line in sys.stdin: count += 1 line = line.strip() if (line.startswith('#')): print line else: vcfr = VCFrecord(line) strchrom = vcfr.get_chr() try: vcfr.set_chr(chrom_map[strchrom]) except: logging.info("Chromosome not found in map %s, %s" % (options.chrommap, strchrom)) exit() print vcfr.get_record() return count