Beispiel #1
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,
	}
}
Beispiel #2
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,
	}
}