This commit is contained in:
2007-06-04 15:34:14 +00:00
parent 7d9ab96dc1
commit adca6d14d9

View File

@ -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)
{