Adds code for the --length option of obiannotate

This commit is contained in:
2023-02-02 17:15:06 +01:00
parent 5639a09fb9
commit 060f7db082
2 changed files with 21 additions and 2 deletions

View File

@ -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
@ -80,6 +90,11 @@ func CLIAnnotationWorker() obiseq.SeqWorker {
annotator = annotator.ChainWorkers(w)
}
if CLIHasSetLengthFlag() {
w := AddSeqLengthWorker()
annotator = annotator.ChainWorkers(w)
}
return annotator
}

View File

@ -128,3 +128,7 @@ func CLIHasTaxonAtRank() bool {
func CLITaxonAtRank() []string {
return _taxonAtRank
}
func CLIHasSetLengthFlag() bool {
return _setSeqLength
}