From 7633fc4d2317658e01c892648d7c3af27df1455d Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Sat, 16 Nov 2024 06:00:27 +0100 Subject: [PATCH] update documentation --- pkg/obiformats/ncbitaxdump/read.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/obiformats/ncbitaxdump/read.go b/pkg/obiformats/ncbitaxdump/read.go index ae5b7e3..1342594 100644 --- a/pkg/obiformats/ncbitaxdump/read.go +++ b/pkg/obiformats/ncbitaxdump/read.go @@ -90,6 +90,17 @@ func loadMergedTable(reader io.Reader, taxonomy *obitax.Taxonomy) int { return n } +// LoadNCBITaxDump loads the NCBI taxonomy data from the specified directory. +// It reads the taxonomy nodes, taxon names, and merged taxa from the corresponding files +// and constructs a Taxonomy object. +// +// Parameters: +// - directory: A string representing the path to the directory containing the NCBI taxonomy dump files. +// - onlysn: A boolean indicating whether to load only scientific names (true) or all names (false). +// +// Returns: +// - A pointer to the obitax.Taxonomy object containing the loaded taxonomy data, or an error +// if any of the files cannot be opened or read. func LoadNCBITaxDump(directory string, onlysn bool) (*obitax.Taxonomy, error) { taxonomy := obitax.NewTaxonomy("NCBI Taxonomy", "taxon", "[[:digit:]]") @@ -144,5 +155,8 @@ func LoadNCBITaxDump(directory string, onlysn bool) (*obitax.Taxonomy, error) { n = loadMergedTable(buffered, taxonomy) log.Printf("%d merged taxa read\n", n) + root := taxonomy.Taxon("1") + taxonomy.SetRoot(root) + return taxonomy, nil }