Add option related to agrep match on obigrep and obiannotate

This commit is contained in:
Eric Coissac
2024-09-09 16:52:13 +02:00
parent 65ae82622e
commit 05bf2bfd6c
12 changed files with 167 additions and 34 deletions

View File

@@ -25,7 +25,7 @@ func DeleteAttributesWorker(toBeDeleted []string) obiseq.SeqWorker {
return f
}
func MatchPatternWorker(pattern, name string, errormax int, allowsIndel bool) obiseq.SeqWorker {
func MatchPatternWorker(pattern, name string, errormax int, bothStrand, allowsIndel bool) obiseq.SeqWorker {
pat, err := obiapat.MakeApatPattern(pattern, errormax, allowsIndel)
if err != nil {
log.Fatalf("error in compiling pattern (%s) : %v", pattern, err)
@@ -56,7 +56,7 @@ func MatchPatternWorker(pattern, name string, errormax int, allowsIndel bool) ob
start, end, nerr, matched := pat.BestMatch(apats, 0, s.Len())
if matched {
if matched && start >= 0 && end <= s.Len() {
annot := s.Annotations()
annot[slot] = pattern
@@ -75,7 +75,7 @@ func MatchPatternWorker(pattern, name string, errormax int, allowsIndel bool) ob
} else {
start, end, nerr, matched := cpat.BestMatch(apats, 0, s.Len())
if matched {
if matched && start >= 0 && end <= s.Len() {
annot := s.Annotations()
annot[slot] = pattern
match, err := s.Subsequence(start, end, false)
@@ -328,9 +328,10 @@ func CLIAnnotationWorker() obiseq.SeqWorker {
}
if CLIHasPattern() {
log.Infof("Match pattern %s with %d error", CLIPattern(), CLIPatternError())
log.Infof("Match pattern %s with %d error", CLIPattern(), obigrep.CLIPatternError())
w := MatchPatternWorker(CLIPattern(), CLIHasPatternName(),
CLIPatternError(), CLIPatternInDels())
obigrep.CLIPatternError(), obigrep.CLIPatternBothStrand(),
obigrep.CLIPatternInDels())
annotator = annotator.ChainWorkers(w)
}

View File

@@ -24,8 +24,6 @@ var _setSeqLength = false
var _uniqueID = false
var _ahoCorazick = ""
var _pattern = ""
var _pattern_error = 0
var _pattern_indel = false
var _pattern_name = "pattern"
var _lcaSlot = ""
var _lcaError = 0.0
@@ -62,14 +60,6 @@ func SequenceAnnotationOptionSet(options *getoptions.GetOpt) {
options.Description("specify the name to use as prefix for the slots reporting the match"),
)
options.IntVar(&_pattern_error, "pattern-error", _pattern_error,
options.Description("Maximum number of allowed error during pattern matching"),
)
options.BoolVar(&_pattern_indel, "allows-indels", _pattern_indel,
options.Description("Allows for indel during pattern matching"),
)
options.StringVar(&_lcaSlot, "add-lca-in", _lcaSlot,
options.ArgName("SLOT_NAME"),
options.Description("From the taxonomic annotation of the sequence (taxid slot or merged_taxid slot), "+
@@ -304,14 +294,6 @@ func CLIHasPatternName() string {
return _pattern_name
}
func CLIPatternError() int {
return _pattern_error
}
func CLIPatternInDels() bool {
return _pattern_indel
}
func CLISetTaxonomicPath() bool {
return _taxonomicPath
}