mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Stabilize the obipairing output. whant run twice on the same dataset results are identical
This commit is contained in:
@ -322,9 +322,13 @@ func PEAlign(seqA, seqB *obiseq.BioSequence,
|
|||||||
}
|
}
|
||||||
extra5 = -startA
|
extra5 = -startA
|
||||||
startB = 0
|
startB = 0
|
||||||
|
|
||||||
rawSeqA = seqA.Sequence()[startA:]
|
rawSeqA = seqA.Sequence()[startA:]
|
||||||
qualSeqA = seqA.Qualities()[startA:]
|
qualSeqA = seqA.Qualities()[startA:]
|
||||||
partLen = len(rawSeqA)
|
partLen = len(rawSeqA)
|
||||||
|
if partLen > seqB.Len() {
|
||||||
|
partLen = seqB.Len()
|
||||||
|
}
|
||||||
rawSeqB = seqB.Sequence()[0:partLen]
|
rawSeqB = seqB.Sequence()[0:partLen]
|
||||||
qualSeqB = seqB.Qualities()[0:partLen]
|
qualSeqB = seqB.Qualities()[0:partLen]
|
||||||
extra3 = seqB.Len() - partLen
|
extra3 = seqB.Len() - partLen
|
||||||
@ -343,6 +347,9 @@ func PEAlign(seqA, seqB *obiseq.BioSequence,
|
|||||||
rawSeqB = seqB.Sequence()[startB:]
|
rawSeqB = seqB.Sequence()[startB:]
|
||||||
qualSeqB = seqB.Qualities()[startB:]
|
qualSeqB = seqB.Qualities()[startB:]
|
||||||
partLen = len(rawSeqB)
|
partLen = len(rawSeqB)
|
||||||
|
if partLen > seqA.Len() {
|
||||||
|
partLen = seqA.Len()
|
||||||
|
}
|
||||||
rawSeqA = seqA.Sequence()[:partLen]
|
rawSeqA = seqA.Sequence()[:partLen]
|
||||||
qualSeqA = seqA.Qualities()[:partLen]
|
qualSeqA = seqA.Qualities()[:partLen]
|
||||||
extra3 = partLen - seqA.Len()
|
extra3 = partLen - seqA.Len()
|
||||||
|
@ -122,6 +122,10 @@ func FastShiftFourMer(index [][]int, seq *obiseq.BioSequence, buffer *[]byte) (i
|
|||||||
if count > maxcount {
|
if count > maxcount {
|
||||||
maxshift = shift
|
maxshift = shift
|
||||||
maxcount = count
|
maxcount = count
|
||||||
|
} else {
|
||||||
|
if count == maxcount && shift < maxshift {
|
||||||
|
maxshift = shift
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,13 +121,14 @@ func AssemblePESequences(seqA, seqB *obiseq.BioSequence,
|
|||||||
lcons := cons.Len()
|
lcons := cons.Len()
|
||||||
aliLength := lcons - _Abs(left) - _Abs(right)
|
aliLength := lcons - _Abs(left) - _Abs(right)
|
||||||
identity := float64(match) / float64(aliLength)
|
identity := float64(match) / float64(aliLength)
|
||||||
|
if aliLength == 0 {
|
||||||
|
identity = 0
|
||||||
|
}
|
||||||
|
annot := cons.Annotations()
|
||||||
|
|
||||||
if aliLength >= minOverlap && identity >= minIdentity {
|
if aliLength >= minOverlap && identity >= minIdentity {
|
||||||
|
annot["mode"] = "alignment"
|
||||||
if withStats {
|
if withStats {
|
||||||
annot := cons.Annotations()
|
|
||||||
annot["mode"] = "alignment"
|
|
||||||
annot["score"] = score
|
|
||||||
|
|
||||||
if left < 0 {
|
if left < 0 {
|
||||||
annot["seq_a_single"] = -left
|
annot["seq_a_single"] = -left
|
||||||
annot["ali_dir"] = "left"
|
annot["ali_dir"] = "left"
|
||||||
@ -142,29 +143,28 @@ func AssemblePESequences(seqA, seqB *obiseq.BioSequence,
|
|||||||
} else {
|
} else {
|
||||||
annot["seq_b_single"] = right
|
annot["seq_b_single"] = right
|
||||||
}
|
}
|
||||||
|
}
|
||||||
scoreNorm := float64(0)
|
if inplace {
|
||||||
if aliLength > 0 {
|
seqA.Recycle()
|
||||||
scoreNorm = math.Round(float64(match)/float64(aliLength)*1000) / 1000
|
seqB.Recycle()
|
||||||
}
|
|
||||||
|
|
||||||
annot["ali_length"] = aliLength
|
|
||||||
annot["seq_ab_match"] = match
|
|
||||||
annot["score_norm"] = scoreNorm
|
|
||||||
|
|
||||||
if inplace {
|
|
||||||
seqA.Recycle()
|
|
||||||
seqB.Recycle()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cons = JoinPairedSequence(seqA, seqB, inplace)
|
cons = JoinPairedSequence(seqA, seqB, inplace)
|
||||||
|
annot = cons.Annotations()
|
||||||
|
annot["mode"] = "join"
|
||||||
|
}
|
||||||
|
|
||||||
if withStats {
|
if withStats {
|
||||||
annot := cons.Annotations()
|
annot["score"] = score
|
||||||
annot["mode"] = "join"
|
scoreNorm := float64(0)
|
||||||
|
if aliLength > 0 {
|
||||||
|
scoreNorm = math.Round(float64(match)/float64(aliLength)*1000) / 1000
|
||||||
|
} else {
|
||||||
|
scoreNorm = 0
|
||||||
}
|
}
|
||||||
|
annot["ali_length"] = aliLength
|
||||||
|
annot["seq_ab_match"] = match
|
||||||
|
annot["score_norm"] = scoreNorm
|
||||||
}
|
}
|
||||||
|
|
||||||
return cons
|
return cons
|
||||||
|
Reference in New Issue
Block a user