@stable(as_of="0.4.0")
    def iter_kmers(self, k, overlap=True):
        if k < 1:
            raise ValueError("k must be greater than 0.")

        if overlap:
            step = 1
            count = len(self) - k + 1
        else:
            step = k
            count = len(self) // k

        if len(self) == 0 or len(self.positional_metadata.columns):
            # Slower path when sequence is empty or positional metadata needs
            # to be sliced.
            for i in range(0, len(self) - k + 1, step):
                yield self[i:i+k]
        else:
            # Optimized path when positional metadata doesn't need slicing.
            kmers = np.lib.stride_tricks.as_strided(
                self._bytes, shape=(k, count), strides=(1, step)).T
            for s in kmers:
                yield self._constructor(
                    sequence=s,
                    metadata=self.metadata,
                    positional_metadata=None)
Generate kmers of length `k` from this sequence.
dataset/ETHPy150Open biocore/scikit-bio/skbio/sequence/_sequence.py/Sequence.iter_kmers