k-mer counter
Counts every k-mer in DNA or a FASTA file, with canonical k-mers and a table you can download.
Counts every k-mer in DNA or a FASTA file, with canonical k-mers and a table you can download.
A k-mer is a substring of length k. A sequence is read one base at a time, and every window of k bases is one k-mer, so the windows overlap: ACGTA holds the 3-mers ACG, CGT and GTA. Counting them turns a sequence into a composition vector that can be compared, clustered or tested for bias, and it is the first step in assembly, read classification, repeat detection and motif discovery.
The share printed next to each count is the count divided by the number of k-mers counted, not by the length of the sequence.
"Try an example" loads a 240 nt sequence built around BamHI sites. With k = 4 there are 240 − 4 + 1 = 237 4-mers, and 78 of the 256 possible 4-mers occur. The most frequent is GATC with 17 counts, 7.2% of the 237, because every GGATCC site contains one. Turn on "Merge reverse complements" and the same sequence gives 50 canonical 4-mers of the 136 possible, with ATCC (ATCC plus GGAT) on top at 24.
Double-stranded DNA carries a k-mer and its reverse complement at the same place. Counting them separately splits one observation in two and makes a genome look more diverse than it is, so read counters, assemblers and sketching tools collapse each pair into one canonicalk-mer, taking whichever of the two comes first alphabetically. Turn the option on for genomic DNA and sequencing reads. Leave it off for mRNA, single-stranded RNA or anything where the strand is part of the answer. An even k has 4k/2 k-mers that are their own reverse complement (GATC, AATT and so on), which is why the canonical total is not simply half.
| k | Possible | Typical use |
|---|---|---|
| 1 | 4 | Base composition, GC content |
| 2 | 16 | Dinucleotide bias, CpG depletion |
| 3 | 64 | Triplet and codon-like composition |
| 4 to 6 | 256 to 4,096 | Motif enrichment, restriction site counts, genome signatures |
| 7 to 10 | 16,384 to 1,048,576 | Repeat and low-complexity work, small reference indexes |
| 21 to 31 | very large | Assembly and read classification, command-line tools only |
A rule of thumb: k is informative while 4k is well above the length of the sequence, and saturated once it is far below. With 240 nt and k = 4 most 4-mers are still missing, while k = 2 would give all 16.
Related composition tools: GC and AT content for the k = 1 case,Shannon entropy for how even the composition is, andtandem repeat finder when a high k-mer count turns out to be one microsatellite.
Paste the sequence or choose a FASTA file, then set k. Every window of k bases is counted, the headline tells you how many of the 4^k possible k-mers actually occur, and the table lists each k-mer with its count and share. Copy or Download gives the whole table as tab-separated text.
A k-mer and its reverse complement are the same piece of double-stranded DNA read from the two strands. "Merge reverse complements" adds the two counts together and reports the alphabetically first of the pair, which is what assemblers and read counters mean by a canonical k-mer. Use it for genomic DNA and sequencing reads; leave it off for single-stranded RNA or when strand matters.
Small k for composition: 1 gives base composition, 2 dinucleotides, 3 codon-like triplets, 4 to 6 the usual motif and bias work. Larger k is for identity: 21 to 31 is common for assembly and read classification, but that needs a command-line counter, not a browser tab. This page allows k from 1 to 10.
Any window that contains a character other than A, C, G, T or U is skipped, so an N does not create a false k-mer and does not silently become an A. The count of skipped windows follows from the totals: a record of length L contributes L − k + 1 windows in all.
A few megabases, such as a bacterial genome, are counted in well under a second, because the file is read and counted on your own device. For large eukaryotic genomes or sets of sequencing reads, and for k above 10, use jellyfish, KMC or BBTools on the command line.