[][src]Module debruijn::kmer

Represent kmers with statically know length in compact integer types

A kmer is a DNA sequence with statically-known length K. The sequence is stored the smallest possible integer type Efficient methods for reverse complement and shifting new bases into the left or right of a sequence are provided. Kmers implement Eq to test if two kmers represent the same string. Kmers implement Ord, which corresponds to the natural lexicographic ordering.

use debruijn::*;
use debruijn::kmer::*;

let k1 = Kmer16::from_ascii(b"ACGTACGTACGTACGT");

// Reverse complement
let rc_k1 = k1.rc();

// Double reverse complement
let k1_copy = rc_k1.rc();
assert_eq!(k1, k1_copy);

// Push one base onto the left
assert_eq!(k1.extend_left(base_to_bits(b'T')), Kmer16::from_ascii(b"TACGTACGTACGTACG"));

// Generate a set of kmers from a string, then sort
let mut all_kmers = Kmer16::kmers_from_ascii(b"TACGTACGTACGTACGTT");
all_kmers.sort();
assert_eq!(all_kmers,
    vec![
        Kmer16::from_ascii(b"ACGTACGTACGTACGT"),
        Kmer16::from_ascii(b"CGTACGTACGTACGTT"),
        Kmer16::from_ascii(b"TACGTACGTACGTACG")
    ]);

Structs

IntKmer

A Kmer sequence with a statically know K. K will fill the underlying integer type.

K2

Marker trait for generating K=6 Kmers

K3

Marker trait for generating K=6 Kmers

K4

Marker trait for generating K=6 Kmers

K5

Marker trait for generating K=6 Kmers

K6

Marker trait for generating K=6 Kmers

K12

Marker trait for generating K=12 Kmers

K14

Marker trait for generating K=14 Kmers

K20

Marker trait for generating K=20 Kmers

K24

Marker trait for generating K=24 Kmers

K30

Marker trait for generating K=30 Kmers

K31

Marker trait for generating K=31 Kmers

K40

Marker trait for generating K=40 Kmers

K48

Marker struct for generating K=48 Kmers

VarIntKmer

A fixed-length Kmer sequence that may not fill the bits of T

Traits

IntHelp

Trait for specialized integer operations used in DeBruijn Graph

KmerSize

Helper trait for declaring the K value of a Kmer. Will be removed when const generics are available

Type Definitions

Kmer2
Kmer3
Kmer4
Kmer5
Kmer6
Kmer8

8-base kmer, backed by a single u16

Kmer12

12-base kmer, backed by a single u32

Kmer14

14-base kmer, backed by a single u32

Kmer16

16-base kmer, backed by a single u32

Kmer20

20-base kmer, backed by a single u64

Kmer24

24-base kmer, backed by a single u64

Kmer30

30-base kmer, backed by a single u64

Kmer32

32-base kmer, backed by a single u64

Kmer40

40-base kmer, backed by a single u128

Kmer48

48-base kmer, backed by a single u128

Kmer64

64-base kmer, backed by a single u128