From adca6d14d9959966e0ff55a0614b88434a910365 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Mon, 4 Jun 2007 15:34:14 +0000 Subject: [PATCH] git-svn-id: https://www.grenoble.prabi.fr/svn/LECASofts/ecoPCR/branches/refactoring@28 60f365c0-8329-0410-b2a4-ec073aeeaa1d --- src/libecoPCR/ecotax.c | 47 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/libecoPCR/ecotax.c b/src/libecoPCR/ecotax.c index 05fdbeb..cb09e7a 100644 --- a/src/libecoPCR/ecotax.c +++ b/src/libecoPCR/ecotax.c @@ -103,7 +103,7 @@ ecotx_t *readnext_ecotaxon(FILE *f,ecotx_t *taxon) "Allocate taxon scientific name"); strncpy(taxon->name,raw->name,raw->namelength); - + return taxon; } @@ -176,6 +176,51 @@ ecotx_t *eco_findtaxonatrank(ecotx_t *taxon, return NULL; } +ecotx_t *eco_findtaxonbytaxid(ecotaxonomy_t *taxonomy, + int32_t taxid) +{ + ecotx_t *current_taxon; + int32_t taxoncount; + int32_t i; + + taxoncount=taxonomy->taxons->count; + + for (current_taxon=taxonomy->taxons->taxon, + i=0; + i < taxoncount; + i++, + current_taxon++) + if (current_taxon->taxid==taxid) + return current_taxon; + + return (ecotx_t*)NULL; +} + +/** + * Find out if taxon is son of other taxon's taxid + * @param *taxon son taxon + * @param parent_taxid taxonomic id of the other taxon + * + * @return 1 is the other taxid math a parent taxid, else 0 + **/ +int eco_isundertaxon(ecotx_t *taxon, + int other_taxid) +{ + ecotx_t *next_parent; + + next_parent = taxon->parent; + + while ( (other_taxid != next_parent->taxid) && (next_parent!=0) ) + { + next_parent = next_parent->parent; + } + + if (other_taxid == next_parent->taxid) + return 1; + else + return 0; +} + ecotx_t *eco_getspecies(ecotx_t *taxon, ecotaxonomy_t *taxonomy) {