From b4afd784dcaef1efff8e0d9d871f02537cbf6dc8 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Wed, 6 Mar 2024 12:52:22 -0300 Subject: [PATCH] few small correction Former-commit-id: 9319387ef5379b66e008233dbd7b6ea60b5d3b1e --- pkg/obiiter/paired.go | 2 +- pkg/obingslibrary/match.go | 5 +++++ pkg/obitools/obisplit/obisplit.go | 30 ++++++++++++++++++++++++------ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/pkg/obiiter/paired.go b/pkg/obiiter/paired.go index a0a36d8..862537b 100644 --- a/pkg/obiiter/paired.go +++ b/pkg/obiiter/paired.go @@ -1,7 +1,7 @@ package obiiter import ( - "log" + log "github.com/sirupsen/logrus" ) func (b BioSequenceBatch) IsPaired() bool { diff --git a/pkg/obingslibrary/match.go b/pkg/obingslibrary/match.go index 1512717..898bf13 100644 --- a/pkg/obingslibrary/match.go +++ b/pkg/obingslibrary/match.go @@ -182,6 +182,11 @@ func (marker *Marker) Match(sequence *obiseq.BioSequence) *DemultiplexMatch { return &m } + // + // At this point the forward primer didn't match. + // We try now with the reverse primer + // + start, end, nerr, matched = marker.reverse.BestMatch(aseq, marker.taglength, -1) if matched { diff --git a/pkg/obitools/obisplit/obisplit.go b/pkg/obitools/obisplit/obisplit.go index 136b445..55ef75b 100644 --- a/pkg/obitools/obisplit/obisplit.go +++ b/pkg/obitools/obisplit/obisplit.go @@ -124,7 +124,7 @@ func SplitPattern(sequence *obiseq.BioSequence, matches := LocatePatterns(sequence, patterns) from := Pattern_match{ - name: "5extremity", + name: "extremity", pattern: "", match: "", begin: 0, @@ -169,10 +169,19 @@ func SplitPattern(sequence *obiseq.BioSequence, if from.name == to.name { sub.SetAttribute("obisplit_group", from.name) } else { - sub.SetAttribute("obisplit_group", fmt.Sprintf("%s-%s", from.name, to.name)) + fname := from.name + tname := to.name + if tname == "extremity" { + fname, tname = tname, fname + } else { + if tname < fname && fname != "extremity" { + fname, tname = tname, fname + } + } + sub.SetAttribute("obisplit_group", fmt.Sprintf("%s-%s", fname, tname)) } - sub.SetAttribute("obisplit_location", fmt.Sprintf("%d..%d", start, end)) + sub.SetAttribute("obisplit_location", fmt.Sprintf("%d..%d", start+1, end)) sub.SetAttribute("obisplit_right_error", to.nerrors) sub.SetAttribute("obisplit_left_error", from.nerrors) @@ -191,7 +200,7 @@ func SplitPattern(sequence *obiseq.BioSequence, if from.end < sequence.Len() { to := Pattern_match{ - name: "3extremity", + name: "extremity", pattern: "", match: "", begin: sequence.Len(), @@ -218,9 +227,18 @@ func SplitPattern(sequence *obiseq.BioSequence, if from.name == to.name { sub.SetAttribute("obisplit_group", from.name) } else { - sub.SetAttribute("obisplit_group", fmt.Sprintf("%s-%s", from.name, to.name)) + fname := from.name + tname := to.name + if tname == "extremity" { + fname, tname = tname, fname + } else { + if tname < fname && fname != "extremity" { + fname, tname = tname, fname + } + } + sub.SetAttribute("obisplit_group", fmt.Sprintf("%s-%s", fname, tname)) } - sub.SetAttribute("obisplit_location", fmt.Sprintf("%d..%d", start, end)) + sub.SetAttribute("obisplit_location", fmt.Sprintf("%d..%d", start+1, end)) sub.SetAttribute("obisplit_right_error", to.nerrors) sub.SetAttribute("obisplit_left_error", from.nerrors)