mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-08 16:50:27 +00:00
Add the --with-taxon-at-rank option code to obiannotate
This commit is contained in:
@@ -3,6 +3,7 @@ package obiannotate
|
||||
import (
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitax"
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obigrep"
|
||||
)
|
||||
|
||||
@@ -43,6 +44,17 @@ func RenameAttributeWorker(toBeRenamed map[string]string) obiseq.SeqWorker {
|
||||
return f
|
||||
}
|
||||
|
||||
func AddTaxonAtRankWorker(taxonomy *obitax.Taxonomy, ranks ...string) obiseq.SeqWorker {
|
||||
f := func(s *obiseq.BioSequence) *obiseq.BioSequence {
|
||||
for _, r := range ranks {
|
||||
taxonomy.SetTaxonAtRank(s,r)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
func CLIAnnotationWorker() obiseq.SeqWorker {
|
||||
var annotator obiseq.SeqWorker
|
||||
annotator = nil
|
||||
@@ -62,6 +74,12 @@ func CLIAnnotationWorker() obiseq.SeqWorker {
|
||||
annotator = annotator.ChainWorkers(w)
|
||||
}
|
||||
|
||||
if CLIHasTaxonAtRank() {
|
||||
taxo := obigrep.CLILoadSelectedTaxonomy()
|
||||
w := AddTaxonAtRankWorker(taxo,CLITaxonAtRank()...)
|
||||
annotator = annotator.ChainWorkers(w)
|
||||
}
|
||||
|
||||
return annotator
|
||||
}
|
||||
|
||||
|
||||
@@ -112,12 +112,19 @@ func CLIHasToBeKeptAttributes() bool {
|
||||
}
|
||||
|
||||
func CLIToBeKeptAttributes() map[string]bool {
|
||||
d := make(map[string]bool,len(_keepOnly))
|
||||
d := make(map[string]bool, len(_keepOnly))
|
||||
|
||||
for _,v := range _keepOnly {
|
||||
d[v]=true
|
||||
for _, v := range _keepOnly {
|
||||
d[v] = true
|
||||
}
|
||||
|
||||
return d
|
||||
}
|
||||
|
||||
func CLIHasTaxonAtRank() bool {
|
||||
return len(_taxonAtRank) > 0
|
||||
}
|
||||
|
||||
func CLITaxonAtRank() []string {
|
||||
return _taxonAtRank
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user