/******************************************************************** * OBIDMS taxonomy header file * ********************************************************************/ /** * @file obidms_taxonomy.h * @author Celine Mercier (celine.mercier@metabarcoding.org) * @date March 2nd 2016 * @brief Header file for the functions handling the reading of binary taxonomy files. */ #include #include #include #include "obidms.h" #define SWAPINT32(x) ((((x) << 24) & 0xFF000000) | (((x) << 8) & 0xFF0000) | \ (((x) >> 8) & 0xFF00) | (((x) >> 24) & 0xFF)) typedef struct { int32_t taxid; int32_t rank; int32_t parent; int32_t name_length; char name[1]; } ecotxformat_t; typedef struct ecotxnode { int32_t taxid; int32_t rank; int32_t farest; int32_t idx; struct ecotxnode* parent; char* name; } ecotx_t; typedef struct { int32_t count; int32_t max_taxid; int32_t buffer_size; ecotx_t taxon[1]; } ecotxidx_t; typedef struct { int32_t count; char* label[1]; } ecorankidx_t; typedef struct { int32_t is_scientific_name; int32_t name_length; int32_t class_length; int32_t taxid; // taxid idx char names[1]; } econameformat_t; typedef struct { char* name; char* class_name; int32_t is_scientific_name; struct ecotxnode* taxon; } econame_t; typedef struct { int32_t count; econame_t names[1]; } econameidx_t; typedef struct OBIDMS_taxonomy_t { ecorankidx_t* ranks; econameidx_t* names; ecotxidx_t* taxa; } OBIDMS_taxonomy_t, *OBIDMS_taxonomy_p; OBIDMS_taxonomy_p obi_read_taxonomy(OBIDMS_p dms, const char* taxonomy_name, bool read_alternative_names); int obi_close_taxonomy(OBIDMS_taxonomy_p taxonomy); ecotx_t* obi_taxo_get_parent_at_rank(ecotx_t* taxon, int32_t rankidx); ecotx_t* obi_taxo_get_taxon_with_taxid(OBIDMS_taxonomy_p taxonomy, int32_t taxid); bool obi_taxo_is_taxon_under_taxid(ecotx_t* taxon, int32_t other_taxid); ecotx_t* obi_taxo_get_species(ecotx_t* taxon, OBIDMS_taxonomy_p taxonomy); ecotx_t* obi_taxo_get_genus(ecotx_t* taxon, OBIDMS_taxonomy_p taxonomy); ecotx_t* obi_taxo_get_family(ecotx_t* taxon, OBIDMS_taxonomy_p taxonomy); 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); int write_rankidx(OBIDMS_p dms, OBIDMS_taxonomy_p tax, const char* taxonomy_name); int write_taxonomyidx(OBIDMS_p dms, OBIDMS_taxonomy_p tax, const char* taxonomy_name); int write_nameidx(OBIDMS_p dms, OBIDMS_taxonomy_p tax, const char* taxonomy_name);