code: def fromimpute2(args):
      
      p = OptionParser(fromimpute2.__doc__)
      opts, args = p.parse_args(args)
  
      if len(args) != 3:
          sys.exit(not p.print_help())
  
      impute2file, fastafile, chr = args
      fasta = Fasta(fastafile)
      print(get_vcfstanza(fastafile, fasta))
      fp = open(impute2file)
      seen = set()
      for row in fp:
          snp_id, rsid, pos, ref, alt, aa, ab, bb = row.split()
          pos = int(pos)
          if pos in seen:
              continue
          seen.add(pos)
          code = max((float(aa), "0/0"), (float(ab), "0/1"), (float(bb), "1/1"))[-1]
          tag = "PR" if snp_id == chr else "IM"
          print("\t".join(str(x) for x in \
                  (chr, pos, rsid, ref, alt, ".", ".", tag, \
                  "GT:GP", code + ":" + ",".join((aa, ab, bb)))))
docs: %prog fromimpute2 impute2file fastafile 1
  
      Convert impute2 output to vcf file. Imputed file looks like:
  
      --- 1:10177:A:AC 10177 A AC 0.451 0.547 0.002