Beispiel #1
0
func findOverlaps(i int, r runner.Runner, reads []read) ([]readPair, error) {

	step := int(len(reads) / r.NumRoutines())
	start := step * i
	end := start + step
	if end > len(reads) {
		end = len(reads)
	}
	var ret []readPair
	for i := start; i < end; i++ {
		tR := &reads[i]
		minLen := 40
		minLenRead := -1
		for j, pR := range reads {
			if i == j {
				continue
			}
			lenOverlap := suffixPrefixMatch(tR.Seq, pR.Seq, minLen)
			if lenOverlap > minLen {
				minLen = lenOverlap
				minLenRead = j
			} else if lenOverlap == minLen {
				minLenRead = -1
			}
		}
		if minLenRead != -1 {
			ret = append(ret, readPair{
				Left: tR, Right: &reads[minLenRead], Overlap: minLen,
			})
		}
		// maxLen := 40
		// var maxRead *read
		// matches, exists := prefixMap[tR.Seq[len(tR.Seq)-40:]]
		// if !exists {
		// 	continue
		// }
		// for j := range matches {
		// 	pR := &reads[j]
		// 	if tR.Label == pR.Label {
		// 		continue
		// 	}
		// 	lenO := suffixPrefixMatch(tR.Seq, pR.Seq, maxLen)
		// 	if lenO > maxLen {
		// 		maxLen = lenO
		// 		maxRead = pR
		// 	} else if lenO == maxLen {
		// 		maxRead = nil
		// 	}
		// }
		// if maxRead != nil {
		// 	ret = append(ret, readPair{
		// 		Left: tR, Right: maxRead, Overlap: maxLen,
		// 	})
		// }
	}

	return ret, nil
}
Beispiel #2
0
func computeMatrix(i int, r runner.Runner, unitigs []*fullUnitig) ([][]int, error) {
	step := int(len(unitigs) / r.NumRoutines())
	start := step * i
	end := start + step
	if end > len(unitigs) {
		end = len(unitigs)
	}
	results := make([][]int, end-start)

	for i := range results {
		results[i] = make([]int, len(unitigs))
	}
	for i := start; i < end; i++ {
		for j := range unitigs {
			if i == j {
				results[i-start][j] = -1
				continue
			}
			results[i-start][j] = suffixPrefixMatch(unitigs[i].Seq, unitigs[j].Seq, 0)
		}
	}

	return results, nil
}