code: def fasta2bed(fastafile):
      
      dustfasta = fastafile.rsplit(".", 1)[0] + ".dust.fasta"
      for name, seq in parse_fasta(dustfasta):
          for islower, ss in groupby(enumerate(seq), key=lambda x: x[-1].islower()):
              if not islower:
                  continue
              ss = list(ss)
              ms, mn = min(ss)
              xs, xn = max(ss)
              print("\t".join(str(x) for x in (name, ms, xs)))
docs: Alternative BED generation from FASTA file. Used for sanity check.