code: def bed(args):
      
      p = OptionParser(bed.__doc__)
  
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(p.print_help())
  
      flist = args
      prefix = flist[0].split(".")[0]
  
      j = 0
      for f in flist:
          reader = Maf(f).reader
          for rec in reader:
              a, b = rec.components
  
              for a, tag in zip((a, b), "ab"):
                  name = "{0}_{1:07d}{2}".format(prefix, j, tag)
                  print("\t".join(str(x) for x in (a.src, a.forward_strand_start, \
                          a.forward_strand_end, name)))
  
              j += 1
docs: %prog bed maffiles > out.bed
  
      Convert a folder of maf alignments to the bed features
      then useful to check coverage, etc.