code: def validate(args):
      
      from jcvi.formats.bed import intersectBed_wao
  
      p = OptionParser(validate.__doc__)
      opts, args = p.parse_args(args)
  
      if len(args) != 2:
          sys.exit(not p.print_help())
  
      fractionation, cdsbed = args
      fp = open(fractionation)
  
      sbed = "S.bed"
      fw = open(sbed, "w")
      for row in fp:
          a, b, c = row.split()
          if not c.startswith("[S]"):
              continue
  
          tag, (seqid, start, end) = get_tag(c, None)
          print("\t".join(str(x) for x in (seqid, start - 1, end, b)), file=fw)
  
      fw.close()
  
      pairs = {}
      for a, b in intersectBed_wao(sbed, cdsbed):
          if b is None:
              continue
          pairs[a.accn] = b.accn
  
      validated = fractionation + ".validated"
      fw = open(validated, "w")
      fp.seek(0)
      fixed = 0
      for row in fp:
          a, b, c = row.split()
          if b in pairs:
              assert c.startswith("[S]")
              c = pairs[b]
              fixed += 1
  
          print("\t".join((a, b, c)), file=fw)
  
      logging.debug("Fixed {0} [S] cases in `{1}`.".format(fixed, validated))
      fw.close()
docs: %prog validate diploid.napus.fractionation cds.bed
  
      Check whether [S] intervals overlap with CDS.