mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Adds code for the --length option of obiannotate
This commit is contained in:
@ -47,7 +47,7 @@ func RenameAttributeWorker(toBeRenamed map[string]string) obiseq.SeqWorker {
|
||||
func AddTaxonAtRankWorker(taxonomy *obitax.Taxonomy, ranks ...string) obiseq.SeqWorker {
|
||||
f := func(s *obiseq.BioSequence) *obiseq.BioSequence {
|
||||
for _, r := range ranks {
|
||||
taxonomy.SetTaxonAtRank(s,r)
|
||||
taxonomy.SetTaxonAtRank(s, r)
|
||||
}
|
||||
return s
|
||||
}
|
||||
@ -55,6 +55,16 @@ func AddTaxonAtRankWorker(taxonomy *obitax.Taxonomy, ranks ...string) obiseq.Seq
|
||||
return f
|
||||
}
|
||||
|
||||
func AddSeqLengthWorker() obiseq.SeqWorker {
|
||||
f := func(s *obiseq.BioSequence) *obiseq.BioSequence {
|
||||
s.SetAttribute("seq_length", s.Len())
|
||||
return s
|
||||
}
|
||||
|
||||
return f
|
||||
|
||||
}
|
||||
|
||||
func CLIAnnotationWorker() obiseq.SeqWorker {
|
||||
var annotator obiseq.SeqWorker
|
||||
annotator = nil
|
||||
@ -76,7 +86,12 @@ func CLIAnnotationWorker() obiseq.SeqWorker {
|
||||
|
||||
if CLIHasTaxonAtRank() {
|
||||
taxo := obigrep.CLILoadSelectedTaxonomy()
|
||||
w := AddTaxonAtRankWorker(taxo,CLITaxonAtRank()...)
|
||||
w := AddTaxonAtRankWorker(taxo, CLITaxonAtRank()...)
|
||||
annotator = annotator.ChainWorkers(w)
|
||||
}
|
||||
|
||||
if CLIHasSetLengthFlag() {
|
||||
w := AddSeqLengthWorker()
|
||||
annotator = annotator.ChainWorkers(w)
|
||||
}
|
||||
|
||||
|
@ -128,3 +128,7 @@ func CLIHasTaxonAtRank() bool {
|
||||
func CLITaxonAtRank() []string {
|
||||
return _taxonAtRank
|
||||
}
|
||||
|
||||
func CLIHasSetLengthFlag() bool {
|
||||
return _setSeqLength
|
||||
}
|
Reference in New Issue
Block a user