Documentation
¶
Index ¶
- Variables
- func Canonical(code uint64, k int) uint64
- func Complement(code uint64, k int) uint64
- func Decode(code uint64, k int) []byte
- func Encode(kmer []byte) (code uint64, err error)
- func EncodeFromFormerKmer(kmer []byte, leftKmer []byte, leftCode uint64) (uint64, error)
- func EncodeFromLatterKmer(kmer []byte, rightKmer []byte, rightCode uint64) (uint64, error)
- func MustCanonical(code uint64, k int) uint64
- func MustComplement(code uint64, k int) uint64
- func MustDecode(code uint64, k int) []byte
- func MustEncodeFromFormerKmer(kmer []byte, leftKmer []byte, leftCode uint64) (uint64, error)
- func MustEncodeFromLatterKmer(kmer []byte, rightKmer []byte, rightCode uint64) (uint64, error)
- func MustRevComp(code uint64, k int) (c uint64)
- func MustReverse(code uint64, k int) (c uint64)
- func RevComp(code uint64, k int) (c uint64)
- func Reverse(code uint64, k int) (c uint64)
- type CodeSlice
- type KmerCode
- func (kcode KmerCode) BitsString() string
- func (kcode KmerCode) Bytes() []byte
- func (kcode KmerCode) Canonical() KmerCode
- func (kcode KmerCode) Comp() KmerCode
- func (kcode KmerCode) Equal(kcode2 KmerCode) bool
- func (kcode KmerCode) Rev() KmerCode
- func (kcode KmerCode) RevComp() KmerCode
- func (kcode KmerCode) String() string
- type KmerCodeSlice
Constants ¶
This section is empty.
Variables ¶
var ErrCodeOverflow = errors.New("kmers: code value overflow")
ErrCodeOverflow means the encode interger is bigger than 4^k.
var ErrIllegalBase = errors.New("kmers: illegal base")
ErrIllegalBase means that base beyond IUPAC symbols are detected.
var ErrKMismatch = errors.New("kmers: K mismatch")
ErrKMismatch means K size mismatch.
var ErrKOverflow = errors.New("kmers: k-mer size (1-32) overflow")
ErrKOverflow means K > 32.
var ErrNotConsecutiveKmers = errors.New("kmers: not consecutive k-mers")
ErrNotConsecutiveKmers means the two k-mers are not consecutive.
var MaxCode []uint64
MaxCode is the maxinum interger for all Ks.
Functions ¶
func Complement ¶
Complement returns code of complement sequence.
func Encode ¶
Encode converts byte slice to bits.
Codes:
A 0b00 C 0b01 G 0b10 T 0b11
For degenerate bases, only the first base is kept.
M AC A V ACG A H ACT A R AG A D AGT A W AT A S CG C B CGT C Y CT C K GT G N ACGT A
func EncodeFromFormerKmer ¶
EncodeFromFormerKmer encodes from the former k-mer, inspired by ntHash
func EncodeFromLatterKmer ¶
EncodeFromLatterKmer encodes from the former k-mer.
func MustCanonical ¶
MustCanonical is similar to Canonical, but does not check k.
func MustComplement ¶
MustComplement is similar to Complement, but does not check k.
func MustDecode ¶
MustDecode is similar to Decode, but does not check k and code.
func MustEncodeFromFormerKmer ¶
MustEncodeFromFormerKmer encodes from former the k-mer, assuming the k-mer and leftKmer are both OK.
func MustEncodeFromLatterKmer ¶
MustEncodeFromLatterKmer encodes from the latter k-mer, assuming the k-mer and rightKmer are both OK.
func MustRevComp ¶
MustRevComp is similar to RevComp, but does not check k.
func MustReverse ¶
MustReverse is similar to Reverse, but does not check k.
Types ¶
type KmerCode ¶
KmerCode is a struct representing a k-mer in 64-bits.
func NewKmerCode ¶
NewKmerCode returns a new KmerCode struct from byte slice.
func NewKmerCodeFromFormerOne ¶
NewKmerCodeFromFormerOne computes KmerCode from the Former consecutive k-mer.
func NewKmerCodeMustFromFormerOne ¶
func NewKmerCodeMustFromFormerOne(kmer []byte, leftKmer []byte, preKcode KmerCode) (KmerCode, error)
NewKmerCodeMustFromFormerOne computes KmerCode from the Former consecutive k-mer, assuming the k-mer and leftKmer are both OK.
func (KmerCode) BitsString ¶
BitsString returns code to string
type KmerCodeSlice ¶
type KmerCodeSlice []KmerCode
KmerCodeSlice is a slice of KmerCode, for sorting
func (KmerCodeSlice) Less ¶
func (codes KmerCodeSlice) Less(i, j int) bool
Less simply compare two KmerCode