skbio.sequence.DNASequence.k_word_frequencies

DNASequence.k_word_frequencies(k, overlapping=True)[source]

Get the frequencies of words of length k

Parameters:

k : int

The word length.

overlapping : bool, optional

Defines whether the k-words should be overlapping or not overlapping.

Returns:

collections.defaultdict

The frequencies of words of length k contained in the BiologicalSequence.

Examples

>>> from skbio.sequence import BiologicalSequence
>>> s = BiologicalSequence('ACACAT')
>>> s.k_word_frequencies(3, overlapping=True)
defaultdict(<type 'int'>, {'CAC': 0.25, 'ACA': 0.5, 'CAT': 0.25})