mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Add the --taxonomic-path option to obiannotate
Former-commit-id: 385309a1c4bc5ed33aeaafc63eedb9fc552f78a6
This commit is contained in:
@ -2,6 +2,7 @@ package obitax
|
||||
|
||||
import (
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obiseq"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Setting the taxon at a given rank for a given sequence.
|
||||
@ -46,3 +47,22 @@ func (taxonomy *Taxonomy) SetGenus(sequence *obiseq.BioSequence) *TaxNode {
|
||||
func (taxonomy *Taxonomy) SetFamily(sequence *obiseq.BioSequence) *TaxNode {
|
||||
return taxonomy.SetTaxonAtRank(sequence, "family")
|
||||
}
|
||||
|
||||
func (taxonomy *Taxonomy) SetPath(sequence *obiseq.BioSequence) string {
|
||||
taxid, err := taxonomy.Taxon(sequence.Taxid())
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Taxid %d not defined in the current taxonomy", sequence.Taxid())
|
||||
}
|
||||
|
||||
path, err := taxid.Path()
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Taxonomy index error: %v", err)
|
||||
}
|
||||
|
||||
tpath := path.String()
|
||||
sequence.SetAttribute("taxonomic_path", tpath)
|
||||
|
||||
return tpath
|
||||
}
|
||||
|
Reference in New Issue
Block a user