K Mer Counter Calculator
Count and analyze k-mers in DNA/RNA sequences. Calculate k-mer frequencies, sequence complexity, GC-rich k-mers, and visualize the most common
K Mer Counter Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser โ no data is sent to any server.
Formula: Total k-mers = L - k + 1; Complexity = Unique k-mers / 4^k
Worked example โ Total: 10 k-mers, 4 unique, 6.25% complexity (highly repetitive sequence)
Formula
Total k-mers = L - k + 1; Complexity = Unique k-mers / 4^k
Where L is the sequence length, k is the k-mer size, and 4^k represents all possible DNA k-mers of length k. Complexity measures the fraction of possible k-mers that actually appear in the sequence.
Worked Examples
Example 1: K-mer Analysis of a Short DNA Sequence
Problem:Given the DNA sequence ATCGATCGATCG (12 bp), count all 3-mers and determine the sequence complexity.
Solution:Total 3-mers = 12 - 3 + 1 = 10 3-mers: ATC(x3), TCG(x3), CGA(x2), GAT(x2) Unique 3-mers = 4 Possible 3-mers = 4^3 = 64 Complexity = 4/64 = 6.25%
Result:Total: 10 k-mers, 4 unique, 6.25% complexity (highly repetitive sequence)
Example 2: Comparing K-mer Sizes on a Repeat Region
Problem:For the sequence ATATATATATATAT (14 bp), compare 2-mer vs 3-mer counts.
Solution:2-mer analysis: Total = 13, Unique = 2 (AT, TA), Possible = 16, Complexity = 12.5% 3-mer analysis: Total = 12, Unique = 2 (ATA, TAT), Possible = 64, Complexity = 3.13% Larger k reveals lower complexity in this tandem repeat.
Result:2-mers: 12.5% complexity | 3-mers: 3.13% complexity. Larger k better exposes the repetitive nature.
Frequently Asked Questions
What are k-mers and why are they important in bioinformatics?
K-mers are all possible subsequences of length k from a given nucleotide or protein sequence. They are fundamental building blocks in bioinformatics for genome assembly, sequence comparison, and error correction. For example, the sequence ATCGA has three 3-mers: ATC, TCG, and CGA. K-mer analysis is used in de Bruijn graph-based assemblers like Velvet and SPAdes, where the genome is reconstructed from overlapping k-mers. They also help estimate genome size, detect contamination, and identify repetitive regions without needing alignment.
How do I choose the right k-mer size for my analysis?
The optimal k-mer size depends on your application and organism complexity. Smaller k values (k=15-21) are useful for error correction and work well with low-coverage data, but may produce many false overlaps in repetitive genomes. Larger k values (k=31-127) improve specificity and resolve repeats better but require higher coverage and more memory. For bacterial genomes, k=21-31 often works well. For human genome assembly, k=51-101 is common. Many modern tools like SPAdes use multiple k-mer sizes simultaneously to balance sensitivity and specificity.
What does k-mer complexity or linguistic complexity mean?
K-mer complexity (also called linguistic complexity) is the ratio of observed unique k-mers to the total number of possible k-mers (4^k for DNA). A complexity of 100% means every possible k-mer of that size appears at least once. Low complexity indicates a repetitive or biased sequence. For instance, the sequence AAAAAAA has only one 3-mer (AAA), giving a complexity of 1/64 = 1.56%. This metric helps identify low-complexity regions that may confound analyses and is used by tools like DUST and RepeatMasker for masking repetitive elements.
Why count k-mers on both strands?
DNA is double-stranded, and biological processes read both strands. When analyzing genomic data, a k-mer and its reverse complement represent the same genomic feature. For example, the 3-mer ATG on the forward strand corresponds to CAT on the reverse strand. Counting both strands together (canonical k-mer counting) gives a more accurate representation of sequence content. Tools like Jellyfish and KMC use canonical k-mers by default. This is especially important for genome assembly and k-mer spectrum analysis where strand-agnostic counts are needed.
How is k-mer counting used in genome size estimation?
K-mer frequency histograms from whole-genome sequencing data can estimate genome size without assembly. The principle is: Genome Size = Total k-mers / Peak k-mer coverage. You plot a histogram of k-mer frequencies, identify the main peak (representing single-copy regions), and divide the total number of k-mers by that peak depth. For example, if you have 3 billion total 21-mers and the coverage peak is at 30x, the estimated genome size is ~100 Mb. Tools like GenomeScope and KmerGenie automate this process and can also estimate heterozygosity and repeat content from the histogram shape.
How do k-mers build a de Bruijn graph?
In the de Bruijn formulation, each distinct k-mer becomes an edge and each of its two overlapping (k-1)-mers, the prefix and the suffix, becomes a node. Reads are shattered into k-mers and threaded into this graph, so reconstructing the sequence turns into finding a path that uses each edge once, an Eulerian path, rather than comparing every read against every other read. The payoff is that assembly cost scales with genome size and k rather than with the square of the read count.
Why is an odd value of k preferred for canonical counting?
Canonical counting collapses each k-mer with its reverse complement so that ATG and CAT are tallied once. That collapse is clean only if no word can be its own reverse complement. A palindromic self-complement requires the central base to pair with itself, which is impossible when the length is odd, so choosing an odd k guarantees every canonical pair contains two genuinely distinct words. With even k, self-complementary words such as GATC form a special case that has to be handled separately in the counter.
How do sequencing errors show up in a k-mer frequency histogram?
A single miscalled base corrupts every window that spans it, generating up to k novel k-mers that almost certainly appear nowhere else in the data. Across millions of reads this produces an enormous spike of k-mers seen exactly once or twice, sitting to the left of the true coverage peak. Analyses therefore apply a low-count cutoff to strip that error tail before estimating genome size or building a graph. A cutoff set too high also deletes genuine low-coverage and rare heterozygous k-mers.
What makes k-mer profiles useful for alignment-free comparison?
Two genomes can be compared by treating each as a set of k-mers and measuring set overlap, typically with the Jaccard index, without ever aligning a base. Sketching methods such as MinHash keep only a small hashed subsample of each set, so whole-genome distances can be estimated in seconds from a few thousand values. The same principle drives metagenomic classification, where a read is assigned to a taxon by which reference k-mers it contains and resolved to a lowest common ancestor when the matches are shared.
Why does the complexity percentage drop when I increase k?
Complexity divides observed unique k-mers by the 4 to the power k possible words, and that denominator explodes while the numerator often does not. A perfect (AT)n tandem repeat contains just two distinct k-mers at any k: AT and TA at k = 2 for 2/16, ATA and TAT at k = 3 for 2/64. Even a random sequence cannot reach high complexity unless it is longer than the word space, since a sequence of length L supplies at most L - k + 1 windows. Compare complexity values only at a fixed k.
References
Background & Theory
History
Reviewed for accuracy by Daniel Agrici, Founder & Lead Developer ยท Editorial policy
Related Calculators
๐งฎAlpaca Gestation Calculator
Calculate alpaca gestation with inputs, formulas, and instant results.
๐งฎCat Pregnancy Calculator โ Due Date & Gestation
Calculate cat pregnancy with inputs, formulas, and instant results.
๐งฎCow Gestation Calculator
Calculate cow gestation with inputs, formulas, and instant results.
๐งฎDog Pregnancy Calculator: Due Date by Breed
Calculate dog pregnancy with inputs, formulas, and instant results.
๐งฎGoat Gestation Calculator
Calculate goat gestation with inputs, formulas, and instant results.
๐งฎGuinea Pig Pregnancy Calculator โ Due Date
Calculate guinea pig pregnancy with inputs, formulas, and instant results.
๐งฎLlama Gestation Calculator
Calculate llama gestation with inputs, formulas, and instant results.
๐งฎMare Gestation Calculator
Calculate mare gestation with inputs, formulas, and instant results.