Changes to be committed:

modified:   .gitignore
	new file:   pkg/obitax/default_taxonomy.go
	modified:   pkg/obitax/taxon.go
	modified:   pkg/obitax/taxonnode.go
	modified:   pkg/obitax/taxonomy.go
	modified:   pkg/obitax/taxonset.go
	modified:   pkg/obitax/taxonslice.go
	modified:   pkg/obitools/obifind/iterator.go
	modified:   pkg/obitools/obifind/options.go
This commit is contained in:
Eric Coissac
2024-11-16 10:01:49 +01:00
parent f3d8707c08
commit 36327c79c8
9 changed files with 153 additions and 87 deletions

View File

@@ -35,10 +35,17 @@ type TaxNode struct {
// Returns:
// - A formatted string representing the TaxNode in the form "taxonomyCode:id [scientificName]".
func (node *TaxNode) String(taxonomyCode string) string {
return fmt.Sprintf("%s:%v [%s]",
if node.HasScientificName() {
return fmt.Sprintf("%s:%v [%s]",
taxonomyCode,
*node.id,
node.ScientificName())
}
return fmt.Sprintf("%s:%v",
taxonomyCode,
*node.id,
node.ScientificName())
*node.id)
}
// Id returns the unique identifier of the TaxNode.
@@ -59,6 +66,10 @@ func (node *TaxNode) ParentId() *string {
return node.parent
}
func (node *TaxNode) HasScientificName() bool {
return node != nil && node.scientificname != nil
}
// ScientificName returns the scientific name of the TaxNode.
// It dereferences the pointer to the scientific name string associated with the taxon node.
//