git-svn-id: https://www.grenoble.prabi.fr/svn/LECASofts/ecoPCR/branches/refactoring@79 60f365c0-8329-0410-b2a4-ec073aeeaa1d
This commit is contained in:
@ -48,8 +48,7 @@ static void printheader(void)
|
|||||||
/**
|
/**
|
||||||
* display son's list for given taxon
|
* display son's list for given taxon
|
||||||
**/
|
**/
|
||||||
|
static void get_son(ecotaxonomy_t *taxonomy, ecotx_t *taxon, int32_t *count, char *rankname)
|
||||||
static void get_son(ecotaxonomy_t *taxonomy, ecotx_t *taxon, int32_t *count)
|
|
||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i;
|
||||||
ecotx_t *current_taxon;
|
ecotx_t *current_taxon;
|
||||||
@ -60,9 +59,12 @@ static void get_son(ecotaxonomy_t *taxonomy, ecotx_t *taxon, int32_t *count)
|
|||||||
{
|
{
|
||||||
if (taxon->taxid == current_taxon->parent->taxid)
|
if (taxon->taxid == current_taxon->parent->taxid)
|
||||||
{
|
{
|
||||||
(*count)++;
|
if (rankname == NULL || !strcmp(rankname,taxonomy->ranks->label[current_taxon->rank]))
|
||||||
printresult(current_taxon, NULL, taxonomy);
|
{
|
||||||
get_son(taxonomy,current_taxon,count);
|
printresult(current_taxon, NULL, taxonomy);
|
||||||
|
(*count)++;
|
||||||
|
}
|
||||||
|
get_son(taxonomy,current_taxon,count,rankname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,7 +95,7 @@ static void listfilteroptions(ecorankidx_t *ranks)
|
|||||||
/* get back on given taxid taxonomic parent */
|
/* get back on given taxid taxonomic parent */
|
||||||
/* and display it */
|
/* and display it */
|
||||||
/* ---------------------------------------- */
|
/* ---------------------------------------- */
|
||||||
void gettaxidparents(int32_t taxid, ecotaxonomy_t *taxonomy)
|
void gettaxidparents(int32_t taxid, ecotaxonomy_t *taxonomy, char *rankname)
|
||||||
{
|
{
|
||||||
ecotx_t *next_parent;
|
ecotx_t *next_parent;
|
||||||
int32_t c = 0;
|
int32_t c = 0;
|
||||||
@ -101,12 +103,17 @@ void gettaxidparents(int32_t taxid, ecotaxonomy_t *taxonomy)
|
|||||||
next_parent = eco_findtaxonbytaxid(taxonomy, taxid);
|
next_parent = eco_findtaxonbytaxid(taxonomy, taxid);
|
||||||
|
|
||||||
printheader();
|
printheader();
|
||||||
|
|
||||||
|
printresult(next_parent, NULL,taxonomy);
|
||||||
|
|
||||||
while ( strcmp(next_parent->name, "root") )
|
while ( strcmp(next_parent->name, "root") )
|
||||||
{
|
{
|
||||||
printresult(next_parent, NULL,taxonomy);
|
|
||||||
next_parent = next_parent->parent;
|
next_parent = next_parent->parent;
|
||||||
c++;
|
if (rankname == NULL || !strcmp(rankname,taxonomy->ranks->label[next_parent->rank]))
|
||||||
|
{
|
||||||
|
printresult(next_parent, NULL,taxonomy);
|
||||||
|
c++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("# %d parent(s) found\n#\n",c);
|
printf("# %d parent(s) found\n#\n",c);
|
||||||
@ -139,27 +146,26 @@ static void PrintHelp()
|
|||||||
PP "------------------------------------------\n");
|
PP "------------------------------------------\n");
|
||||||
PP " ecofind Version %s\n", VERSION);
|
PP " ecofind Version %s\n", VERSION);
|
||||||
PP "------------------------------------------\n");
|
PP "------------------------------------------\n");
|
||||||
PP "synopsis : searching for scientific name, taxonomic\n");
|
PP "synopsis : searching for taxonomic and rank and\n");
|
||||||
PP " rank and taxonomy id for given regular\n");
|
PP " taxonomy id for given regular expression patterns\n\n");
|
||||||
PP " expression patterns\n");
|
PP "usage: ecofind [options] <patterns>\n");
|
||||||
PP "usage: ecofind [options] pattern\n");
|
|
||||||
PP "------------------------------------------\n");
|
PP "------------------------------------------\n");
|
||||||
PP "options:\n");
|
PP "options:\n");
|
||||||
PP "-d : [D]atabase containing the taxonomy\n");
|
PP "-a : [A]ll enable the search on all alternative names and not only scientific names.\n\n");
|
||||||
PP " to match the expected format, the database\n");
|
PP "-d : [D]atabase containing the taxonomy.\n");
|
||||||
PP " has to be formated first by the ecoPCRFormat.py\n");
|
PP " To match the expected format, the database\n");
|
||||||
PP " program located in the tools directory.\n");
|
PP " has to be formated first by the ecoPCRFormat.py\n");
|
||||||
PP " Write the database radical without any extension.\n\n");
|
PP " program located in the tools directory.\n");
|
||||||
PP "-h : [H]elp - print <this> help\n\n");
|
PP " Write the database radical without any extension.\n\n");
|
||||||
PP "-l : [L]ist all taxonomic rank available for -r option\n\n");
|
PP "-h : [H]elp - print <this> help\n\n");
|
||||||
PP "-p : [P]arent's taxonomic id. Specifiying this option will display ");
|
PP "-l : [L]ist all taxonomic rank available for -r option\n\n");
|
||||||
PP " all parent's information for the given taxid.\n\n");
|
PP "-p : [P]arents : specifiying this option displays all parental tree's information for the given taxid.\n\n");
|
||||||
PP "-r : [R]estrict to given taxonomic rank\n\n");
|
PP "-r : [R]estrict to given taxonomic rank\n\n");
|
||||||
PP "-s : [S]on's taxonomic id. Specifiying this option will display ");
|
PP "-s : [S]ons: specifiying this option displays all subtree's information for the given taxid.\n\n");
|
||||||
PP " all son's information for the given taxid.\n\n");
|
PP "arguments:\n");
|
||||||
PP "<taxon> name pattern bearing regular expressions\n\n");
|
PP "<taxon> name pattern bearing regular expressions\n\n");
|
||||||
PP "------------------------------------------\n");
|
PP "------------------------------------------\n");
|
||||||
PP " https://www.grenoble.prabi.fr/trac/ecoPCR/wiki\n");
|
PP " http://www.grenoble.prabi.fr/trac/ecoPCR/\n");
|
||||||
PP "------------------------------------------\n\n");
|
PP "------------------------------------------\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +251,7 @@ int main(int argc, char **argv)
|
|||||||
errflag++;
|
errflag++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errflag && !uptree && !rankname && !subtree)
|
if (errflag && !uptree && !rankname && !subtree && !list)
|
||||||
ExitUsage(errflag);
|
ExitUsage(errflag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -274,7 +280,7 @@ int main(int argc, char **argv)
|
|||||||
/* ---------------------------------------- */
|
/* ---------------------------------------- */
|
||||||
if (uptree)
|
if (uptree)
|
||||||
{
|
{
|
||||||
gettaxidparents(uptree,taxonomy);
|
gettaxidparents(uptree,taxonomy,rankname);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +292,8 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
printheader();
|
printheader();
|
||||||
subtree_parent = eco_findtaxonbytaxid(taxonomy,subtree);
|
subtree_parent = eco_findtaxonbytaxid(taxonomy,subtree);
|
||||||
get_son(taxonomy, subtree_parent,&count_son);
|
printresult(subtree_parent, NULL,taxonomy);
|
||||||
|
get_son(taxonomy, subtree_parent,&count_son,rankname);
|
||||||
printf("# %d son(s) found\n#\n",count_son);
|
printf("# %d son(s) found\n#\n",count_son);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user