bioin.frequency_map

bioin.frequency_map(text, k)[source]

Find the frequency of all k-mers in a string.

Parameters:
  • text (str) – text.
  • k (int) – length of the substring (i.e. kmers).
Returns:

Dictionary, a dictionary that contains the count of all the k-mers in text.

Examples

Computes the frequency map of a given string (i.e. text) and integer (i.e. k). Return a dictionary of the k-mers and the corresponding frequency for all k-mers that appears in text.

>>> text = "CGATATATCCATAG"
>>> k = 3
>>> kmers_count_map = frequency_map(text, k)
>>> kmers_count_map
    {'CGA': 1, 'GAT': 1, 'ATA': 3, 'TAT': 2, 'ATC': 1, 'TCC': 1, 'CCA': 1, 'CAT': 1, 'TAG': 1}