New version of LCS computation, with abug on alignment length patched patched

This commit is contained in:
2022-11-15 08:21:46 +01:00
parent 18be4becec
commit 340579f6d7
5 changed files with 238 additions and 383 deletions

View File

@@ -360,14 +360,14 @@ func extendSimilarityGraph(seqs *[]*seqPCR, step int, workers int) int {
nseq := len(*seqs)
running := sync.WaitGroup{}
linePairs := func(matrix *obialign.LCSMatrix, i int) {
linePairs := func(matrix *[]uint64, i int) {
son := (*seqs)[i]
for j := i + 1; j < nseq; j++ {
father := (*seqs)[j]
d, _, _, _ := obialign.D1Or0(son.Sequence, father.Sequence)
if d < 0 {
lcs, lali := obialign.LCSScore(son.Sequence, father.Sequence,
lcs, lali := obialign.FastLCSScore(son.Sequence, father.Sequence,
step,
matrix)
d := (lali - lcs)
@@ -385,9 +385,10 @@ func extendSimilarityGraph(seqs *[]*seqPCR, step int, workers int) int {
// idxChan := make(chan [][]Ratio)
ff := func() {
matrix := obialign.NewLCSMatrix(nil, 150, 150, step)
var matrix []uint64
for i := range lineChan {
linePairs(matrix, i)
linePairs(&matrix, i)
}
running.Done()

View File

@@ -22,34 +22,26 @@ func FindClosests(sequence *obiseq.BioSequence,
refcounts []*obikmer.Table4mer,
runExact bool) (obiseq.BioSequenceSlice, int, float64, string, []int) {
matrix := obialign.NewLCSMatrix(nil,
sequence.Length(),
sequence.Length(),
sequence.Length())
var matrix []uint64
seqwords := obikmer.Count4Mer(sequence, nil, nil)
cw := make([]int, len(refcounts))
for i, ref := range refcounts {
cw[i] = obikmer.Common4Mer(seqwords, ref)
// if i < 50 {
// print(cw[i])
// print(";")
// }
}
// print("\n")
o := goutils.ReverseIntOrder(cw)
mcw := 100000
for _, i := range o {
if cw[i] < mcw {
mcw = cw[i]
}
if cw[i] > mcw {
log.Panicln("wrong order")
}
}
// mcw := 100000
// for _, i := range o {
// if cw[i] < mcw {
// mcw = cw[i]
// }
// if cw[i] > mcw {
// log.Panicln("wrong order")
// }
// }
bests := obiseq.MakeBioSequenceSlice()
bests = append(bests, references[o[0]])
@@ -74,7 +66,8 @@ func FindClosests(sequence *obiseq.BioSequence,
// log.Println(sequence.Id(),cw[j], maxe)
if runExact || (atMost <= (maxe + 1)) {
lcs, alilength := obialign.LCSScore(sequence, ref, maxe+1, matrix)
lcs, alilength := obialign.FastLCSScore(sequence, ref, maxe+1,&matrix)
// lcs, alilength := obialign.LCSScore(sequence, ref, maxe+1, matrix)
n++
if lcs == -1 {
nf++