/******************************************************************** * 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 MIN_LOCAL_TAXID (10000000) #define TAX_NAME_LEN (1024) typedef struct { int32_t taxid; int32_t rank; int32_t parent; int32_t name_length; char name[]; } ecotxformat_t; typedef struct ecotxnode { int32_t taxid; // TODO discuss that this is will be the current taxid even if the struct was accessed through a deprecated one int32_t rank; int32_t farest; int32_t idx; struct ecotxnode* parent; char* name; bool local; } ecotx_t; typedef struct { int32_t count; int32_t ncbi_count; int32_t local_count; int32_t max_taxid; int32_t buffer_size; ecotx_t taxon[]; } ecotxidx_t; typedef struct { int32_t count; char* label[]; } ecorankidx_t; typedef struct { int32_t is_scientific_name; int32_t name_length; int32_t class_length; int32_t taxid; // taxid idx char names[]; } 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[]; } econameidx_t; typedef struct { int32_t taxid; int32_t idx; } ecomerged_t; typedef struct { int32_t count; ecomerged_t merged[]; } ecomergedidx_t; typedef struct OBIDMS_taxonomy_t { char tax_name[TAX_NAME_LEN]; OBIDMS_p dms; ecomergedidx_t* merged_idx; 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 obi_write_taxonomy(OBIDMS_p dms, OBIDMS_taxonomy_p tax, const char* tax_name); OBIDMS_taxonomy_p obi_read_taxdump(const char* taxdump); int obi_taxonomy_add_local_taxon(OBIDMS_taxonomy_p tax, const char* name, const char* rank_name, int32_t parent_taxid, int32_t min_taxid);