code: def validate(args):
      
      import pyfasta
  
      p = OptionParser(validate.__doc__)
      p.add_option("--prefix", help="Add prefix to seqid")
      opts, args = p.parse_args(args)
  
      vcffile, fastafile = args
      pf = opts.prefix
      genome = pyfasta.Fasta(fastafile, record_class=pyfasta.MemoryRecord)
      fp = must_open(vcffile)
      match_ref = match_alt = total = 0
      for row in fp:
          if row[0] == '#':
              continue
          seqid, pos, id, ref, alt = row.split()[:5]
          total += 1
          if pf:
              seqid = pf + seqid
          pos = int(pos)
          if seqid not in genome:
              continue
          true_ref = genome[seqid][pos - 1]
          if total % 100000 == 0:
              print(total, "sites parsed", file=sys.stderr)
          if ref == true_ref:
              match_ref += 1
          elif alt == true_ref:
              match_alt += 1
  
      logging.debug("Match REF: {}".format(percentage(match_ref, total)))
      logging.debug("Match ALT: {}".format(percentage(match_alt, total)))
docs: %prog validate input.vcf genome.fasta
  
      Fasta validation of vcf file.