mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-08 08:40:26 +00:00
Add the --taxonomic-path option to obiannotate
Former-commit-id: 385309a1c4bc5ed33aeaafc63eedb9fc552f78a6
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
package obitax
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type TaxonSlice []*TaxNode
|
||||
|
||||
func (set *TaxonSlice) Get(i int) *TaxNode {
|
||||
@@ -9,3 +14,25 @@ func (set *TaxonSlice) Get(i int) *TaxNode {
|
||||
func (set *TaxonSlice) Len() int {
|
||||
return len(*set)
|
||||
}
|
||||
|
||||
func (path *TaxonSlice) String() string {
|
||||
var buffer bytes.Buffer
|
||||
|
||||
if len(*path) > 0 {
|
||||
taxon := (*path)[len(*path)-1]
|
||||
fmt.Fprintf(&buffer, "%d@%s@%s",
|
||||
taxon.Taxid(),
|
||||
taxon.ScientificName(),
|
||||
taxon.Rank())
|
||||
|
||||
for i := len(*path) - 2; i >= 0; i-- {
|
||||
taxon := (*path)[i]
|
||||
fmt.Fprintf(&buffer, "|%d@%s@%s",
|
||||
taxon.Taxid(),
|
||||
taxon.ScientificName(),
|
||||
taxon.Rank())
|
||||
}
|
||||
}
|
||||
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user