skbio.sequence.Sequence.iter_kmers¶

Sequence.
iter_kmers
(k, overlap=True)[source]¶ Generate kmers of length k from this sequence.
State: Stable as of 0.4.0.
 Parameters
 Yields
Sequence – kmer of length k contained in this sequence.
 Raises
ValueError – If k is less than 1.
Examples
>>> from skbio import Sequence >>> s = Sequence('ACACGACGTT') >>> for kmer in s.iter_kmers(4, overlap=False): ... str(kmer) 'ACAC' 'GACG' >>> for kmer in s.iter_kmers(3, overlap=True): ... str(kmer) 'ACA' 'CAC' 'ACG' 'CGA' 'GAC' 'ACG' 'CGT' 'GTT'