Adds option to tune the pairing of the sequences in obipairing and some stats to the results

Former-commit-id: a6cf9cb4d4ab20a433a2534fd7d11cd3ca8ebbaa
This commit is contained in:
2023-11-24 12:29:37 +01:00
parent ec31ae86b9
commit b556e045e5
7 changed files with 178 additions and 102 deletions

View File

@@ -13,6 +13,8 @@ var _MinOverlap = 20
var _GapPenality = float64(2.0)
var _WithoutStats = false
var _MinIdentity = 0.9
var _NoFastAlign = false
var _FastScoreAbs = false
func PairingOptionSet(options *getoptions.GetOpt) {
options.StringVar(&_ForwardFile, "forward-reads", "",
@@ -39,6 +41,10 @@ func PairingOptionSet(options *getoptions.GetOpt) {
options.BoolVar(&_WithoutStats, "without-stat", _WithoutStats,
options.Alias("S"),
options.Description("Remove alignment statistics from the produced consensus sequences."))
options.BoolVar(&_NoFastAlign, "exact-mode", _NoFastAlign,
options.Description("Do not run fast alignment heuristic."))
options.BoolVar(&_FastScoreAbs, "fast-absolute", _FastScoreAbs,
options.Description("Compute absolute fast score (no action in exact mode)."))
}
func OptionSet(options *getoptions.GetOpt) {
@@ -82,3 +88,11 @@ func CLIGapPenality() float64 {
func CLIWithStats() bool {
return !_WithoutStats
}
func CLIFastMode() bool {
return !_NoFastAlign
}
func CLIFastRelativeScore() bool {
return !_FastScoreAbs
}

View File

@@ -99,16 +99,18 @@ func JoinPairedSequence(seqA, seqB *obiseq.BioSequence, inplace bool) *obiseq.Bi
// destroyed during the assembling process and cannot be reuse later on.
// the gap and delta parametters.
//
// - fastModeRel: if set to true, the FAST score mode is set to relative score
//
// # Returns
//
// An obiseq.BioSequence corresponding to the assembling of the both
// input sequence.
func AssemblePESequences(seqA, seqB *obiseq.BioSequence,
gap float64, delta, minOverlap int, minIdentity float64, withStats bool,
inplace bool,
inplace bool, fastAlign, fastModeRel bool,
arenaAlign obialign.PEAlignArena) *obiseq.BioSequence {
score, path, fastscore, over := obialign.PEAlign(seqA, seqB, gap, delta, arenaAlign)
score, path, fastcount, over, fastscore := obialign.PEAlign(seqA, seqB, gap, fastAlign, delta, fastModeRel, arenaAlign)
cons, match := obialign.BuildQualityConsensus(seqA, seqB, path, true)
left := path[0]
@@ -123,8 +125,12 @@ func AssemblePESequences(seqA, seqB *obiseq.BioSequence,
identity = 0
}
annot := cons.Annotations()
annot["paring_fast_score"] = fastscore
annot["paring_fast_overlap"] = over
if fastAlign {
annot["paring_fast_count"] = fastcount
annot["paring_fast_score"] = math.Round(fastscore*1000) / 1000
annot["paring_fast_overlap"] = over
}
if aliLength >= minOverlap && identity >= minIdentity {
annot["mode"] = "alignment"
@@ -205,7 +211,7 @@ func AssemblePESequences(seqA, seqB *obiseq.BioSequence,
// each pair of processed sequences produces one sequence in the result iterator.
func IAssemblePESequencesBatch(iterator obiiter.IBioSequence,
gap float64, delta, minOverlap int,
minIdentity float64,
minIdentity float64, fastAlign, fastModeRel,
withStats bool, sizes ...int) obiiter.IBioSequence {
if !iterator.IsPaired() {
@@ -235,7 +241,7 @@ func IAssemblePESequencesBatch(iterator obiiter.IBioSequence,
cons := make(obiseq.BioSequenceSlice, len(batch.Slice()))
for i, A := range batch.Slice() {
B := A.PairedWith()
cons[i] = AssemblePESequences(A, B.ReverseComplement(true), gap, delta, minOverlap, minIdentity, withStats, true, arena)
cons[i] = AssemblePESequences(A, B.ReverseComplement(true), gap, delta, minOverlap, minIdentity, withStats, true, fastAlign, fastModeRel, arena)
}
newIter.Push(obiiter.MakeBioSequenceBatch(
batch.Order(),

View File

@@ -14,7 +14,7 @@ import (
func IPCRTagPESequencesBatch(iterator obiiter.IBioSequence,
gap float64, delta, minOverlap int,
minIdentity float64,
minIdentity float64, fastAlign, fastScoreRel,
withStats bool) obiiter.IBioSequence {
if !iterator.IsPaired() {
@@ -50,7 +50,8 @@ func IPCRTagPESequencesBatch(iterator obiiter.IBioSequence,
B := A.PairedWith()
consensus := obipairing.AssemblePESequences(
A.Copy(), B.ReverseComplement(false),
gap, delta, minOverlap, minIdentity, withStats, true, arena,
gap, delta, minOverlap, minIdentity, withStats, true,
fastAlign, fastScoreRel, arena,
)
consensus, err = ngsfilter.ExtractBarcode(consensus, true)