Skip to main content
`Ctrl`+`K`

# skbio.sequence.Protein.iter_kmers

Protein.iter_kmers(k, overlap=True)

  Generate kmers of length k from this sequence.

  Parameters:
    k int

      The kmer length.

    overlap bool, optional

      Defines whether the kmers should be overlapping or not.

  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'