util

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CtrlByte2ByteLengths = [64][2]uint8{
	{1, 1},
	{1, 2},
	{1, 3},
	{1, 4},
	{1, 5},
	{1, 6},
	{1, 7},
	{1, 8},
	{2, 1},
	{2, 2},
	{2, 3},
	{2, 4},
	{2, 5},
	{2, 6},
	{2, 7},
	{2, 8},
	{3, 1},
	{3, 2},
	{3, 3},
	{3, 4},
	{3, 5},
	{3, 6},
	{3, 7},
	{3, 8},
	{4, 1},
	{4, 2},
	{4, 3},
	{4, 4},
	{4, 5},
	{4, 6},
	{4, 7},
	{4, 8},
	{5, 1},
	{5, 2},
	{5, 3},
	{5, 4},
	{5, 5},
	{5, 6},
	{5, 7},
	{5, 8},
	{6, 1},
	{6, 2},
	{6, 3},
	{6, 4},
	{6, 5},
	{6, 6},
	{6, 7},
	{6, 8},
	{7, 1},
	{7, 2},
	{7, 3},
	{7, 4},
	{7, 5},
	{7, 6},
	{7, 7},
	{7, 8},
	{8, 1},
	{8, 2},
	{8, 3},
	{8, 4},
	{8, 5},
	{8, 6},
	{8, 7},
	{8, 8},
}

CtrlByte2ByteLengths is a table for query byte lenghts from the control byte.

Functions

func ByteLength

func ByteLength(n uint64) uint8

ByteLength returns the minimum number of bytes to store a integer.

func KmerBaseAt

func KmerBaseAt(code uint64, k uint8, i uint8) uint8

KmerBaseAt returns the base in pos i (0-based).

func KmerHasPrefix

func KmerHasPrefix(code uint64, prefix uint64, k1, k2 uint8) bool

KmerHasPrefix checks if a k-mer has a prefix.

func KmerLongestPrefix

func KmerLongestPrefix(code1, code2 uint64, k1, k2 uint8) uint8

KmerLongestPrefix returns the length of the longest prefix.

func KmerPrefix

func KmerPrefix(code uint64, k uint8, n uint8) uint64

KmerPrefix returns the first n bases. n needs to be > 0. The length of the prefix is n.

func KmerSuffix

func KmerSuffix(code uint64, k uint8, i uint8) uint64

KmerSuffix returns the suffix starting from position i (0-based). The length of the suffix is k - commonPrefix.

func MustKmerHasPrefix

func MustKmerHasPrefix(code uint64, prefix uint64, k1, k2 uint8) bool

MustKmerHasPrefix checks if a k-mer has a prefix, by assuming k1>=k2.

func MustKmerLongestPrefix

func MustKmerLongestPrefix(code1, code2 uint64, k1, k2 uint8) uint8

MustKmerLongestPrefix returns the length of the longest prefix. We assume k1 >= k2.

func MustSharingPrefixKmersMismatch

func MustSharingPrefixKmersMismatch(code1, code2 uint64, k, p uint8) (n uint8)

MustSharingPrefixKmersMismatch counts the number of mismatch between two k-mers sharing with a p-bp prefix. This function assumes p<k.

func PutUint64s

func PutUint64s(buf []byte, v1, v2 uint64) (ctrl byte, n int)

PutUint64s encodes two uint64s into 2-16 bytes, and returns control byte and encoded byte length.

func ReverseInts

func ReverseInts(s []int)

ReverseInts reverses a list of ints

func SharingPrefixKmersMismatch

func SharingPrefixKmersMismatch(code1, code2 uint64, k, p uint8) (n uint8)

SharingPrefixKmersMismatch counts the number of mismatch between two k-mers sharing with a p-bp prefix.

func Uint64s

func Uint64s(ctrl byte, buf []byte) (values [2]uint64, n int)

Uint64s decodes encoded bytes.

func UniqUint64s

func UniqUint64s(list *[]uint64)

UniqUint64s removes duplicates in a uint64 list

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL