Kmer

value class Kmer(val encoding: Long) : Comparable<Kmer>

2-bit encoded representation of a short nucleotide sequence (32 bases or fewer) Encoding: A=0, C=1, T/U=2, G=3 For kmers smaller than 32 bp, leftmost digits are padded with 0 Ambiguous bases (eg. N) are not allowed

val kmer = Kmer(1432462)
val kmerFromString = Kmer("UGCACUGCCA")
val kmerFromSeq = Kmer(NucSeq("TCTCACCTACA")

val kmerFromString = Kmer("NTACCGANNTCG") // throw error - ambiguous bases
val kmerFromString = Kmer("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT") // throw error - string too long

Constructors

Link copied to clipboard
constructor(encoding: Long)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open operator override fun compareTo(other: Kmer): Int

Follows comparisons of bits represented as unsigned long

Link copied to clipboard
fun hammingDistance(other: Kmer): Int

Returns the Hamming Distance between this Kmer and other Kmer

Link copied to clipboard
fun reverseComplement(kmerSize: Int): Kmer

Returns the reverse complement of a sequence already encoded in a 2-bit long. Note: polyA is used represent unknown, but reverse complement will change it to polyT which does not mean the same. kmerSize parameter is required to remove polyT padding

Link copied to clipboard
fun toSeq(): NucSeq

Converts Kmer to NucSeq Includes any A padding at left

fun toSeq(kmerSize: Int): NucSeq

Converts Kmer to NucSeq, trimming A padding at left to kmerSize

Link copied to clipboard
open override fun toString(): String

Converts 2-bit encoding to string By default, keeps any A padding at left

fun toString(kmerSize: Int): String

Converts 2-bit encoding to string, trimming leftmost bits so the resulting sequence length is kmerSize