mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Work on iterators and recycling of biosequences
This commit is contained in:
@ -3,18 +3,26 @@ package obioptions
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/DavidGamba/go-getoptions"
|
||||
)
|
||||
|
||||
var __debug__ = false
|
||||
var _Debug = false
|
||||
var _ParallelWorkers = runtime.NumCPU() - 1
|
||||
var _BufferSize = 1
|
||||
var _BatchSize = 5000
|
||||
|
||||
type ArgumentParser func([]string) (*getoptions.GetOpt, []string, error)
|
||||
|
||||
func GenerateOptionParser(optionset ...func(*getoptions.GetOpt)) ArgumentParser {
|
||||
options := getoptions.New()
|
||||
options.Bool("help", false, options.Alias("h", "?"))
|
||||
options.BoolVar(&__debug__, "debug", false)
|
||||
options.BoolVar(&_Debug, "debug", false)
|
||||
|
||||
options.IntVar(&_ParallelWorkers, "workers", runtime.NumCPU()-1,
|
||||
options.Alias("w"),
|
||||
options.Description("Number of parallele threads computing the result"))
|
||||
|
||||
for _, o := range optionset {
|
||||
o(options)
|
||||
@ -32,15 +40,33 @@ func GenerateOptionParser(optionset ...func(*getoptions.GetOpt)) ArgumentParser
|
||||
}
|
||||
}
|
||||
|
||||
// Predicate indicating if the debug mode is activated
|
||||
// Predicate indicating if the debug mode is activated.
|
||||
func IsDebugMode() bool {
|
||||
return __debug__
|
||||
return _Debug
|
||||
}
|
||||
|
||||
// ParallelWorkers returns the number of parallel workers requested by
|
||||
// the command line option --workers|-w.
|
||||
func ParallelWorkers() int {
|
||||
return _ParallelWorkers
|
||||
}
|
||||
|
||||
// BufferSize returns the expeted channel buffer size for obitools
|
||||
func BufferSize() int {
|
||||
return _BufferSize
|
||||
}
|
||||
|
||||
// BatchSize returns the expeted size of the sequence batches
|
||||
func BatchSize() int {
|
||||
return _BatchSize
|
||||
}
|
||||
|
||||
// DebugOn sets the debug mode on.
|
||||
func DebugOn() {
|
||||
__debug__ = true
|
||||
_Debug = true
|
||||
}
|
||||
|
||||
// DebugOff sets the debug mode off.
|
||||
func DebugOff() {
|
||||
__debug__ = false
|
||||
_Debug = false
|
||||
}
|
||||
|
Reference in New Issue
Block a user