/kmers

bit-packed k-mers methods for Golang

Primary LanguageGoMIT LicenseMIT

kmers

Go Reference

This package provides manipulations for bit-packed k-mers (k<=32, encoded in uint64).

Methods with names starting with Must are faster by skipping boundary checking.

Related projects:

Benchmark

CPU: AMD Ryzen 7 2700X Eight-Core Processor, 3.7 GHz

$ go test . -bench=Bench* -benchmem \
    | grep Bench \
    | perl -pe 's/\s\s+/\t/g' \
    | csvtk cut -Ht -f 1,3-5 \
    | csvtk add-header -t -n test,time,memory,allocs \
    | csvtk pretty -t -r

                                      test           time     memory        allocs
------------------------------------------   ------------   --------   -----------
                     BenchmarkEncodeK32-16    19.67 ns/op     0 B/op   0 allocs/op
       BenchmarkEncodeFromFormerKmerK32-16    7.692 ns/op     0 B/op   0 allocs/op
   BenchmarkMustEncodeFromFormerKmerK32-16    2.008 ns/op     0 B/op   0 allocs/op
                     BenchmarkDecodeK32-16    80.73 ns/op    32 B/op   1 allocs/op
                 BenchmarkMustDecodeK32-16    76.93 ns/op    32 B/op   1 allocs/op

                        BenchmarkRevK32-16    3.617 ns/op     0 B/op   0 allocs/op
                       BenchmarkCompK32-16   0.7999 ns/op     0 B/op   0 allocs/op
                    BenchmarkRevCompK32-16    3.814 ns/op     0 B/op   0 allocs/op
                   BenchmarkCannonalK32-16    4.147 ns/op     0 B/op   0 allocs/op

Support

Please open an issue to report bugs, propose new functions or ask for help.

License

MIT License

History

This package was originally maintained in unikmer.