def bed(args):
    '\n    %prog bed fastafile kmer.dump.txt\n\n    Map kmers on FASTA.\n    '
    from jcvi.formats.fasta import rc, parse_fasta
    p = OptionParser(bed.__doc__)
    (opts, args) = p.parse_args(args)
    if (len(args) != 2):
        sys.exit((not p.print_help()))
    (fastafile, dumpfile) = args
    fp = open(dumpfile)
    KMERS = set()
    for row in fp:
        kmer = row.split()[0]
        kmer_rc = rc(kmer)
        KMERS.add(kmer)
        KMERS.add(kmer_rc)
    K = len(kmer)
    logging.debug('Imported {} {}-mers'.format(len(KMERS), K))
    for (name, seq) in parse_fasta(fastafile):
        name = name.split()[0]
        for i in range((len(seq) - K)):
            if ((i % 5000000) == 0):
                print('{}:{}'.format(name, i), file=sys.stderr)
            kmer = seq[i:(i + K)]
            if (kmer in KMERS):
                print('\t'.join((str(x) for x in (name, i, (i + K), kmer))))
%prog bed fastafile kmer.dump.txt

Map kmers on FASTA.
def bed(args):
    '\n    %prog bed fastafile kmer.dump.txt\n\n    Map kmers on FASTA.\n    '
    from jcvi.formats.fasta import rc, parse_fasta
    p = OptionParser(bed.__doc__)
    (opts, args) = p.parse_args(args)
    if (len(args) != 2):
        sys.exit((not p.print_help()))
    (fastafile, dumpfile) = args
    fp = open(dumpfile)
    KMERS = set()
    for row in fp:
        kmer = row.split()[0]
        kmer_rc = rc(kmer)
        KMERS.add(kmer)
        KMERS.add(kmer_rc)
    K = len(kmer)
    logging.debug('Imported {} {}-mers'.format(len(KMERS), K))
    for (name, seq) in parse_fasta(fastafile):
        name = name.split()[0]
        for i in range((len(seq) - K)):
            if ((i % 5000000) == 0):
                print('{}:{}'.format(name, i), file=sys.stderr)
            kmer = seq[i:(i + K)]
            if (kmer in KMERS):
                print('\t'.join((str(x) for x in (name, i, (i + K), kmer))))