Exemplo n.º 1
0
// Create a new Merger using the provided kmerindex, query sequence and filter parameters.
// If selfCompare is true only the upper diagonal of the comparison matrix is checked to save time.
func NewMerger(index *kmerindex.Index, query *seq.Seq, filterParams *Params, selfCompare bool) (m *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,
	}

	m = &Merger{
		target:         index.Seq,
		filterParams:   filterParams,
		query:          query,
		selfComparison: selfCompare,
		bottomPadding:  index.GetK() + 2,
		leftPadding:    leftPadding,
		binWidth:       binWidth,
		eoTerm:         eoTerm,
		trapOrder:      eoTerm,
	}

	return m
}
Exemplo n.º 2
0
// 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
}
Exemplo n.º 3
0
// 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,
	}
}
Exemplo n.º 4
0
// 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,
	}
}