Taxonomy: added functions to check if a taxonomy already exists in a
DMS, and added taxdump import from a compressed file
This commit is contained in:
@ -2740,6 +2740,35 @@ int read_names_dmp(const char* taxdump, OBIDMS_taxonomy_p tax)
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
int obi_taxonomy_exists(OBIDMS_p dms, const char* taxonomy_name)
|
||||
{
|
||||
char* taxonomy_path;
|
||||
DIR* dir;
|
||||
|
||||
taxonomy_path = get_taxonomy_path(dms, taxonomy_name);
|
||||
if (taxonomy_path == NULL)
|
||||
return -1;
|
||||
|
||||
dir = opendir(taxonomy_path);
|
||||
if (dir)
|
||||
{
|
||||
/* Directory exists. */
|
||||
closedir(dir);
|
||||
return 1;
|
||||
}
|
||||
else if (ENOENT == errno)
|
||||
{
|
||||
/* Directory does not exist. */
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* opendir() failed for some other reason. */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OBIDMS_taxonomy_p obi_read_taxdump(const char* taxdump)
|
||||
{
|
||||
OBIDMS_taxonomy_p tax;
|
||||
@ -3705,7 +3734,7 @@ ecotx_t* obi_taxo_get_kingdom(ecotx_t* taxon, OBIDMS_taxonomy_p taxonomy)
|
||||
|
||||
ecotx_t* obi_taxo_get_superkingdom(ecotx_t* taxon, OBIDMS_taxonomy_p taxonomy)
|
||||
{
|
||||
static int32_t rankindex = -1;
|
||||
static int32_t rankindex = -1;
|
||||
|
||||
if (taxonomy == NULL)
|
||||
{
|
||||
@ -3738,3 +3767,23 @@ const char* obi_taxo_rank_index_to_label(int32_t rank_idx, ecorankidx_t* ranks)
|
||||
return (ranks->label)[rank_idx];
|
||||
}
|
||||
|
||||
|
||||
int obi_taxo_is_taxid_included(OBIDMS_taxonomy_p taxonomy,
|
||||
int32_t* restrict_to_taxids,
|
||||
int32_t count,
|
||||
int32_t taxid)
|
||||
{
|
||||
int i;
|
||||
ecotx_t* taxon;
|
||||
|
||||
taxon = obi_taxo_get_taxon_with_taxid(taxonomy, taxid);
|
||||
|
||||
if (taxon)
|
||||
for (i=0; i < count; i++)
|
||||
if ((taxon->taxid == restrict_to_taxids[i]) ||
|
||||
(obi_taxo_is_taxon_under_taxid(taxon, restrict_to_taxids[i])))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user