code: def gaps(args):
      
      from jcvi.formats.base import DictFile
      from jcvi.apps.base import popen
      from jcvi.utils.cbook import percentage
  
      p = OptionParser(gaps.__doc__)
      p.add_option("--bdist", default=0, type="int",
                   help="Base pair distance [default: %default]")
      opts, args = p.parse_args(args)
  
      if len(args) != 3:
          sys.exit(not p.print_help())
  
      idsfile, frfile, gapsbed = args
      bdist = opts.bdist
      d =  DictFile(frfile, keypos=1, valuepos=2)
      bedfile = idsfile + ".bed"
      fw = open(bedfile, "w")
      fp = open(idsfile)
      total = 0
      for row in fp:
          id = row.strip()
          hit = d[id]
          tag, pos = get_tag(hit, None)
          seqid, start, end = pos
          start, end = max(start - bdist, 1), end + bdist
          print("\t".join(str(x) for x in (seqid, start - 1, end, id)), file=fw)
          total += 1
      fw.close()
  
      cmd = "intersectBed -a {0} -b {1} -v | wc -l".format(bedfile, gapsbed)
      not_in_gaps = popen(cmd).read()
      not_in_gaps = int(not_in_gaps)
      in_gaps = total - not_in_gaps
      print("Ids in gaps: {1}".\
              format(total, percentage(in_gaps, total)), file=sys.stderr)
docs: %prog gaps idsfile fractionationfile gapsbed
  
      Check gene locations against gaps. `idsfile` contains a list of IDs to query
      into `fractionationfile` in order to get expected locations.