1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
#include "libecoPCR/ecoPCR.h"
#include <getopt.h>
#include <stdlib.h>
#define VERSION "0.1"
/* ----------------------------------------------- */
/* printout verbose mode */
/* ----------------------------------------------- */
static void printTaxon(ecotx_t *taxon){
printf("# taxid : %d | rank : %d | name : %s \n\n",taxon->taxid, taxon->rank, taxon->name);
}
/* ----------------------------------------------- */
/* printout help */
/* ----------------------------------------------- */
#define PP fprintf(stdout,
static void PrintHelp()
{
PP "\n------------------------------------------\n");
PP " ecoisundertaxon Version %s\n", VERSION);
PP "------------------------------------------\n");
PP " synopsis : searching relationship in taxonomy\n");
PP " usage: ecoisundertaxon [options] database\n");
PP "------------------------------------------\n");
PP " options:\n");
PP " -1 : [FIRST] taxomic id of the hypothetical son\n\n");
PP " -2 : [SECOND] taxonomic id of the hypothetical parent\n\n");
PP " -h : [H]elp - print <this> help\n\n");
PP " -v : [V]erbose mode. Display taxonomic information for both\n");
PP " : taxonomic id.\n\n");
PP "------------------------------------------\n");
PP " database : to match the expected format, the database\n");
PP " has to be formatted first by the ecoPCRFormat.py program located.\n");
PP " in the tools directory. Type the radical only, leaving out the extension\n");
PP "------------------------------------------\n\n");
PP " https://www.grenoble.prabi.fr/trac/ecoPCR/wiki");
PP "------------------------------------------\n\n");
}
#undef PP
/* ----------------------------------------------- */
/* printout usage and exit */
/* ----------------------------------------------- */
#define PP fprintf(stderr,
static void ExitUsage(stat)
int stat;
{
PP "usage: ecoisundertaxon [-1 taxid] [-2 taxid] [-v] [-h] datafile\n");
PP "type \"ecoisundertaxon -h\" for help\n");
if (stat)
exit(stat);
}
#undef PP
/* ----------------------------------------------- */
/* MAIN */
/* ----------------------------------------------- */
int main(int argc, char **argv){
int32_t carg = 0;
int32_t taxid_1 = 0;
int32_t taxid_2 = 0;
int32_t verbose = 0;
int32_t errflag = 0;
ecotaxonomy_t *taxonomy = NULL;
ecotx_t *son = NULL;
ecotx_t *parent = NULL;
while ((carg = getopt(argc, argv, "1:2:vh")) != -1) {
switch (carg) {
case '1':
sscanf(optarg,"%d",&taxid_1);
break;
case '2':
sscanf(optarg,"%d",&taxid_2);
break;
case 'v':
verbose = 1;
break;
case 'h':
PrintHelp();
exit(0);
break;
case '?':
errflag++;
}
}
if ((argc -= optind) != 1)
errflag++;
if (errflag)
ExitUsage(errflag);
taxonomy = read_taxonomy(argv[optind],0);
son = eco_findtaxonbytaxid(taxonomy, taxid_1);
if (verbose){
parent = eco_findtaxonbytaxid(taxonomy, taxid_2);
printTaxon(son);
printTaxon(parent);
}
if (eco_isundertaxon(son, taxid_2))
printf("# taxid_1 (%d) is son of taxid_2 (%d)\n",taxid_1, taxid_2);
else
printf("# taxid_1 (%d) is NOT son of taxid_2 (%d)\n",taxid_1, taxid_2);
return 0;
}
|