mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-08-24 13:51:18 +00:00
fix: respect config defaults when --allowed-mismatches is unset
The change replaces numeric threshold checks with an explicit flag state tracker for the `--allowed-mismatches` option. This ensures per-primer mismatch settings from configuration files are preserved when the CLI parameter is omitted or zero, making the command-line flag act strictly as an explicit override rather than a default fallback.
This commit is contained in:
@@ -777,7 +777,7 @@ func (library *NGSLibrary) ExtractMultiBarcodeSliceWorker(options ...WithOption)
|
||||
library.SetAllowsIndels(true)
|
||||
}
|
||||
|
||||
if opt.AllowedMismatches() > 0 {
|
||||
if opt.AllowedMismatchesIsSet() {
|
||||
library.SetAllowedMismatches(opt.AllowedMismatches())
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,14 @@ import (
|
||||
)
|
||||
|
||||
type _Options struct {
|
||||
discardErrors bool
|
||||
unidentified string
|
||||
allowedMismatch int
|
||||
allowsIndel bool
|
||||
withProgressBar bool
|
||||
parallelWorkers int
|
||||
batchSize int
|
||||
discardErrors bool
|
||||
unidentified string
|
||||
allowedMismatch int
|
||||
allowedMismatchSet bool
|
||||
allowsIndel bool
|
||||
withProgressBar bool
|
||||
parallelWorkers int
|
||||
batchSize int
|
||||
}
|
||||
|
||||
// Options stores a set of option usable by the
|
||||
@@ -52,6 +53,7 @@ func OptionWithProgressBar(yes bool) WithOption {
|
||||
func OptionAllowedMismatches(count int) WithOption {
|
||||
f := WithOption(func(opt Options) {
|
||||
opt.pointer.allowedMismatch = count
|
||||
opt.pointer.allowedMismatchSet = true
|
||||
})
|
||||
|
||||
return f
|
||||
@@ -97,6 +99,12 @@ func (options Options) AllowedMismatches() int {
|
||||
return options.pointer.allowedMismatch
|
||||
}
|
||||
|
||||
// AllowedMismatchesIsSet returns true if OptionAllowedMismatches
|
||||
// was explicitly applied to these options.
|
||||
func (options Options) AllowedMismatchesIsSet() bool {
|
||||
return options.pointer.allowedMismatchSet
|
||||
}
|
||||
|
||||
func (options Options) AllowsIndels() bool {
|
||||
return options.pointer.allowsIndel
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user