code: def top10(args):
      
      from jcvi.formats.base import DictFile
  
      p = OptionParser(top10.__doc__)
      p.add_option("--top", default=10, type="int",
                  help="Top N taxa to extract [default: %default]")
      p.add_option("--ids", default=None,
                  help="Two column ids file to query seqid [default: %default]")
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      blastfile, = args
      mapping = DictFile(opts.ids, delimiter="\t") if opts.ids else {}
  
      cmd = "cut -f2 {0}".format(blastfile)
      cmd += " | sort | uniq -c | sort -k1,1nr | head -n {0}".format(opts.top)
      fp = popen(cmd)
      for row in fp:
          count, seqid = row.split()
          nseqid = mapping.get(seqid, seqid)
          print("\t".join((count, nseqid)))
docs: %prog top10 blastfile.best
  
      Count the most frequent 10 hits. Usually the BLASTFILE needs to be screened
      the get the best match. You can also provide an .ids file to query the ids.
      For example the ids file can contain the seqid to species mapping.
  
      The ids file is two-column, and can sometimes be generated by
      `jcvi.formats.fasta ids --description`.