// Create a new Merger using the provided kmerindex, query sequence, filter parameters and maximum inter-segment gap length. // If selfCompare is true only the upper diagonal of the comparison matrix is examined. func NewMerger(index *kmerindex.Index, query *seq.Seq, filterParams *Params, maxIGap int, selfCompare bool) *Merger { tubeWidth := filterParams.TubeOffset + filterParams.MaxError binWidth := tubeWidth - 1 leftPadding := diagonalPadding + binWidth eoTerm := &Trapezoid{ Left: query.Len() + 1 + leftPadding, Right: query.Len() + 1, Bottom: -1, Top: query.Len() + 1, Next: nil, } return &Merger{ target: index.Seq, filterParams: filterParams, maxIGap: maxIGap, query: query, selfComparison: selfCompare, bottomPadding: index.GetK() + 2, leftPadding: leftPadding, binWidth: binWidth, eoTerm: eoTerm, trapOrder: eoTerm, } }
// Return a new Filter using index as the target and filter parameters in params. func New(index *kmerindex.Index, params *Params) (f *Filter) { f = &Filter{ index: index, target: index.Seq, k: index.GetK(), minMatch: params.MinMatch, maxError: params.MaxError, tubeOffset: params.TubeOffset, } return }
// Create a new KmerRainbow defined by the rectangle r, kmerindex index and background color. func NewKmerRainbow(r image.Rectangle, index *kmerindex.Index, background color.HSVA) *KmerRainbow { // should generalise the BG color h := r.Dy() kmers := make([]int, h) kmask := util.Pow4(index.GetK()) kmaskf := float64(kmask) f := func(index *kmerindex.Index, _, kmer int) { kmers[int(float64(kmer)*float64(h)/kmaskf)]++ } index.ForEachKmerOf(index.Seq, 0, index.Seq.Len(), f) max := util.Max(kmers...) return &KmerRainbow{ RGBA: image.NewRGBA(r), Index: index, Max: max, BackGround: background, } }
// Create a new CGR defined by the kmerindex index and background color. func NewCGR(index *kmerindex.Index, background color.HSVA) *CGR { // should generalise the BG color max := 0 f := func(index *kmerindex.Index, _, kmer int) { if freq := index.FingerAt(kmer); freq > max { max = freq } } index.ForEachKmerOf(index.Seq, 0, index.Seq.Len(), f) k := uint(index.GetK()) return &CGR{ RGBA: image.NewRGBA(image.Rect(0, 0, 1<<k, 1<<k)), Index: index, Max: max, BackGround: background, } }