add the --raw-taxid option

This commit is contained in:
Eric Coissac
2025-03-08 09:40:06 +01:00
parent 78df7db18d
commit b18c9b7ac6
5 changed files with 25 additions and 1 deletions

View File

@ -16,6 +16,12 @@
- A new option **--csv** is added to every obitools to indicate that the input
format is CSV
- The new version of obitools are now printing the taxids in a fancy way
including the scientific name and the taxonomic rank (`"taxon:9606 [Homo
sapiens]@species"`). But if you need the old fashion raw taxid, a new option
**--raw-taxid** has been added to get obitools printing the taxids without any
decorations (`"9606"`).
## March 1st, 2025. Release 4.4.0

View File

@ -4,6 +4,15 @@ var __taxonomy__ = ""
var __alternative_name__ = false
var __fail_on_taxonomy__ = false
var __update_taxid__ = false
var __raw_taxid__ = false
func UseRawTaxids() bool {
return __raw_taxid__
}
func UseRawTaxidsPtr() *bool {
return &__raw_taxid__
}
func SelectedTaxonomy() string {
return __taxonomy__

View File

@ -186,6 +186,10 @@ func LoadTaxonomyOptionSet(options *getoptions.GetOpt, required, alternatiive bo
options.BoolVar(obidefault.UpdateTaxidPtr(), "update-taxid", obidefault.UpdateTaxid(),
options.Description("Make obitools automatically updating the taxid that are declared merged to a newest one."),
)
options.BoolVar(obidefault.UseRawTaxidsPtr(), "raw-taxid", obidefault.UseRawTaxids(),
options.Description("When set, taxids are printed in files with any supplementary information (taxon name and rank)"),
)
}
// CLIIsDebugMode returns whether the CLI is in debug mode.

View File

@ -8,7 +8,7 @@ import (
// corresponds to the last commit, and not the one when the file will be
// commited
var _Commit = "706b44c"
var _Commit = "78df7db"
var _Version = "Release 4.4.0"
// Version returns the version of the obitools package.

View File

@ -5,6 +5,7 @@ import (
"regexp"
"strings"
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obidefault"
log "github.com/sirupsen/logrus"
)
@ -37,6 +38,10 @@ type TaxNode struct {
// Returns:
// - A formatted string representing the TaxNode in the form "taxonomyCode:id [scientificName]@rank".
func (node *TaxNode) String(taxonomyCode string) string {
if obidefault.UseRawTaxids() {
return *node.id
}
if node.HasScientificName() {
return fmt.Sprintf("%s:%v [%s]@%s",
taxonomyCode,