Documentation ¶
Overview ¶
Package kmerindex performs Kmer indexing package based on Bob Edgar and Gene Meyers' approach used in PALS.
Index ¶
- Variables
- func Distance(a, b map[Kmer]float64) (dist float64)
- func Format(kmer Kmer, k int, alpha alphabet.Alphabet) (string, error)
- func GCof(k int, kmer Kmer) float64
- type Eval
- type Index
- func (ki *Index) Build()
- func (ki *Index) Check() (ok bool, found int)
- func (ki *Index) ComplementOf(kmer Kmer) (c Kmer)
- func (ki *Index) Finger() (f []Kmer)
- func (ki *Index) FingerAt(p int) int
- func (ki *Index) ForEachKmerOf(s *linear.Seq, start, end int, f Eval) (err error)
- func (ki *Index) Format(kmer Kmer) string
- func (ki *Index) GCof(kmer Kmer) float64
- func (ki *Index) K() int
- func (ki *Index) KmerFrequencies() (map[Kmer]int, bool)
- func (ki *Index) KmerIndex() (map[Kmer][]int, bool)
- func (ki *Index) KmerOf(kmertext string) (kmer Kmer, err error)
- func (ki *Index) KmerPositions(kmer Kmer) (positions []int, err error)
- func (ki *Index) KmerPositionsString(kmertext string) (positions []int, err error)
- func (ki *Index) NormalisedKmerFrequencies() (map[Kmer]float64, bool)
- func (ki *Index) Pos() (p []int)
- func (ki *Index) PosAt(p int) int
- func (ki *Index) Seq() *linear.Seq
- func (ki *Index) StringKmerIndex() (map[string][]int, bool)
- type Kmer
Constants ¶
This section is empty.
Variables ¶
var ( ErrKTooLarge = errors.New("kmerindex: k too large") ErrKTooSmall = errors.New("kmerindex: k too small") ErrShortSeq = errors.New("kmerindex: sequence to short for k") ErrBadAlphabet = errors.New("kmerindex: alphabet size != 4") ErrBadKmer = errors.New("kmerindex: kmer out of range") ErrBadKmerTextLen = errors.New("kmerindex: kmertext length != k") ErrBadKmerText = errors.New("kmerindex: kmertext contains illegal character") )
var ( MinKmerLen = 4 // default minimum // MaxKmerLen is the maximum Kmer length that can be used. // It is 16 on 64 bit architectures and 14 on 32 bit architectures. MaxKmerLen = 16 - offset )
Constraints on Kmer length.
var Debug = false // Set Debug to true to prevent recovering from panics in ForEachKmer f Eval function.
Functions ¶
func Distance ¶
Return the Euclidean distance between two sequences measured by abolsolute kmer frequencies.
Types ¶
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Kmer index type
func (*Index) Build ¶
func (ki *Index) Build()
Build the Kmer position table destructively replacing Kmer frequencies
func (*Index) Check ¶
Confirm that a Build() is correct. Returns boolean indicating this and the number of kmers indexed.
func (*Index) ComplementOf ¶
Reverse complement a Kmer. Complementation is performed according to letter index:
0, 1, 2, 3 = 3, 2, 1, 0
func (*Index) FingerAt ¶
Returns the value of the finger slice at p. This signifies the absolute kmer frequency of the Kmer(p) if called before Build() and points to the relevant position lookup if called after.
func (*Index) ForEachKmerOf ¶
Applies the f Eval func to all kmers in s from start to end. Returns any panic raised by f as an error.
func (*Index) KmerFrequencies ¶
Return a map containing absolute Kmer frequencies and true if called before Build(). If called after Build returns a nil map and false.
func (*Index) KmerIndex ¶
Returns a Kmer-keyed map containing slices of kmer positions and true if called after Build, otherwise nil and false.
func (*Index) KmerOf ¶
Convert a string of bases into a Kmer, returns an error if string length does not match word length
func (*Index) KmerPositions ¶
Return an array of positions for the Kmer kmer
func (*Index) KmerPositionsString ¶
Return an array of positions for the Kmer string kmertext
func (*Index) NormalisedKmerFrequencies ¶
Return a map containing relative Kmer frequencies and true if called before Build(). If called after Build returns a nil map and false.
type Kmer ¶
type Kmer uint32 // Sensible size for word type uint64 will double the size of the index (already large for high k)
2-bit per base packed word
func ComplementOf ¶
Reverse complement a Kmer of len k. Complementation is performed according to letter index:
0, 1, 2, 3 = 3, 2, 1, 0