Adds the --template option to obimultiplex

Former-commit-id: 349e9f278abd6a6c258f31d99ea04853a79c62de
This commit is contained in:
Eric Coissac
2024-05-31 11:34:06 +02:00
parent 4487723d14
commit 38945d0a41
2 changed files with 33 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"os"
log "github.com/sirupsen/logrus"
@ -31,6 +32,16 @@ func main() {
_, args := optionParser(os.Args)
if obimultiplex.CLIAskConfigTemplate() {
fmt.Print(obimultiplex.CLIConfigTemplate())
os.Exit(0)
}
if !obimultiplex.CLIHasNGSFilterFile() {
log.Error("You must provide a tag list file following the NGSFilter format")
os.Exit(1)
}
sequences, err := obiconvert.CLIReadBioSequences(args...)
if err != nil {

View File

@ -13,6 +13,7 @@ import (
)
var _NGSFilterFile = ""
var _askTemplate = false
var _UnidentifiedFile = ""
var _AllowedMismatch = int(2)
var _AllowsIndel = false
@ -30,7 +31,6 @@ var _ConservedError = false
func MultiplexOptionSet(options *getoptions.GetOpt) {
options.StringVar(&_NGSFilterFile, "tag-list", _NGSFilterFile,
options.Alias("t"),
options.Required("You must provide a tag list file following the NGSFilter format"),
options.Description("File name of the NGSFilter file describing PCRs."))
options.BoolVar(&_ConservedError, "keep-errors", _ConservedError,
@ -47,6 +47,10 @@ func MultiplexOptionSet(options *getoptions.GetOpt) {
options.Alias("e"),
options.Description("Used to specify the number of errors allowed for matching primers."))
options.BoolVar(&_askTemplate, "template", _askTemplate,
options.Description("Print on the standard output an example of CSV configuration file."),
)
}
func OptionSet(options *getoptions.GetOpt) {
@ -69,6 +73,10 @@ func CLIConservedErrors() bool {
return _UnidentifiedFile != "" || _ConservedError
}
func CLIHasNGSFilterFile() bool {
return _NGSFilterFile != ""
}
func CLINGSFIlter() (obingslibrary.NGSLibrary, error) {
file, err := os.Open(_NGSFilterFile)
@ -85,3 +93,16 @@ func CLINGSFIlter() (obingslibrary.NGSLibrary, error) {
return ngsfiler, nil
}
func CLIAskConfigTemplate() bool {
return _askTemplate
}
func CLIConfigTemplate() string {
return `experiment,sample,sample_tag,forward_primer,reverse_primer
wolf_diet,13a_F730603,aattaac,TTAGATACCCCACTATGC,TAGAACAGGCTCCTCTAG
wolf_diet,15a_F730814,gaagtag:gaatatc,TTAGATACCCCACTATGC,TAGAACAGGCTCCTCTAG
wolf_diet,26a_F040644,gaatatc:-,TTAGATACCCCACTATGC,TAGAACAGGCTCCTCTAG
wolf_diet,29a_F260619,-:-,TTAGATACCCCACTATGC,TAGAACAGGCTCCTCTAG
`
}