kmerindex

package
v0.0.0-...-25502c3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2012 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Kmer indexing package based on Bob Edgar and Gene Meyers' approach used in PALS.

Currently limited to Kmers of 15 nucleotides due to int constraints in Go.

Index

Constants

This section is empty.

Variables

View Source
var Debug = false // Set Debug to true to prevent recovering from panics in ForEachKmer f Eval function.
View Source
var MaxKmerLen = 15
View Source
var (
	MinKmerLen = 4 // default minimum
)

Functions

func Distance

func Distance(a, b map[Kmer]float64) (dist float64)

Return the Euclidian distance between two sequences measured by abolsolute kmer frequencies.

func GCof

func GCof(k int, kmer Kmer) float64

Return the GC fraction of a Kmer of len k

func Stringify

func Stringify(k int, kmer Kmer) string

Convert a Kmer into a string of bases

Types

type Eval

type Eval func(index *Index, j, kmer int)

errors should be handled through a panic which will be recovered by ForEachKmerOf

type Index

type Index struct {
	Seq *seq.Seq
	// contains filtered or unexported fields
}

Kmer index type

func New

func New(k int, sequence *seq.Seq) (i *Index, err error)

Create a new Kmer Index with a word size k based on sequence

func (*Index) Build

func (self *Index) Build()

Build the Kmer position table destructively replacing Kmer frequencies

func (*Index) Check

func (self *Index) Check() (ok bool, found int)

Confirm that a Build() is correct. Returns boolean indicating this and the number of kmers indexed.

func (*Index) ComplementOf

func (self *Index) ComplementOf(kmer Kmer) (c Kmer)

Reverse complement a Kmer

func (*Index) Finger

func (self *Index) Finger() (f []Kmer)

Return a copy of the internal finger slice.

func (*Index) FingerAt

func (self *Index) FingerAt(p int) int

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

func (self *Index) ForEachKmerOf(s *seq.Seq, start, end int, f Eval) (err error)

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) GCof

func (self *Index) GCof(kmer Kmer) float64

Return the GC fraction of a Kmer

func (*Index) GetK

func (self *Index) GetK() int

Return the Kmer length of the Index.

func (*Index) GetPositionsKmer

func (self *Index) GetPositionsKmer(kmer Kmer) (positions []int, err error)

Return an array of positions for the Kmer kmer

func (*Index) GetPositionsString

func (self *Index) GetPositionsString(kmertext string) (positions []int, err error)

Return an array of positions for the Kmer string kmertext

func (*Index) GetSeq

func (self *Index) GetSeq() *seq.Seq

Returns a pointer to the indexed seq.Seq.

func (*Index) KmerFrequencies

func (self *Index) KmerFrequencies() (map[Kmer]int, bool)

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

func (self *Index) KmerIndex() (map[Kmer][]int, bool)

Returns a Kmer-keyed map containing slices of kmer positions and true if called after Build, otherwise nil and false.

func (*Index) KmerOf

func (self *Index) KmerOf(kmertext string) (kmer Kmer, err error)

Convert a string of bases into a Kmer, returns an error if string length does not match word length

func (*Index) NormalisedKmerFrequencies

func (self *Index) NormalisedKmerFrequencies() (map[Kmer]float64, bool)

Return a map containing relative Kmer frequencies and true if called before Build(). If called after Build returns a nil map and false.

func (*Index) Pos

func (self *Index) Pos() (p []int)

Return a copy of the internal pos slice.

func (*Index) PosAt

func (self *Index) PosAt(p int) int

Returns the value of the pos slice at p. This signifies the position of the pth kmer if called after Build(). Not valid before Build() - will panic.

func (*Index) StringKmerIndex

func (self *Index) StringKmerIndex() (map[string][]int, bool)

Returns a string-keyed map containing slices of kmer positions and true if called after Build, otherwise nil and false.

func (*Index) Stringify

func (self *Index) Stringify(kmer Kmer) string

Convert a Kmer into a string of bases

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

func ComplementOf(k int, kmer Kmer) (c Kmer)

Reverse complement a Kmer of len k

func KmerOf

func KmerOf(k int, kmertext string) (kmer Kmer, err error)

Convert a string of bases into a len k Kmer, returns an error if string length does not match k

Jump to

Keyboard shortcuts

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