diff --git a/src/ecopcr.c b/src/ecopcr.c index d0a4939..0c9d285 100644 --- a/src/ecopcr.c +++ b/src/ecopcr.c @@ -8,8 +8,8 @@ #define VERSION "0.1" /* ----------------------------------------------- */ -/* printout help */ /* ----------------------------------------------- */ - +/* printout help */ +/* ----------------------------------------------- */ #define PP fprintf(stdout, static void PrintHelp() @@ -21,56 +21,56 @@ static void PrintHelp() PP "usage: ecoPCR [options] datafile\n"); PP "------------------------------------------\n"); PP "options:\n"); - PP "-1 : [FIRST] oligonucleotide for direct strand\n\n"); - PP "-2 : [SECOND] oligonucleotide for reverse strand\n\n"); - PP "-e : [E]rror \n"); - PP " : max error allowed by oligonucleotide\n\n"); - PP "-h : [H]elp - print help\n\n"); - PP "-i : [I]gnore the given taxonomy id.\n"); - PP " taxonomy id are available using the ecofind program.\n"); - PP " see its help typing ecofind -h for more information.\n"); - PP "-k : [K]ingdom mode\n"); - PP " set the kingdom mode\n"); - PP " super kingdom mode by default.\n\n"); - PP "-l : minimum [L]ength\n"); - PP " define the minimum amplication length. \n\n"); - PP "-L : maximum [L]ength\n"); - PP " define the maximum amplicationlength. \n\n"); - PP "-r : [R]estricts the search to the given taxonomy id.\n"); - PP " taxonomy id are available using the ecofind program.\n"); - PP " see its help typing ecofind -h for more information.\n"); + PP "-1 : [FIRST] oligonucleotide for direct strand\n\n"); + PP "-2 : [SECOND] oligonucleotide for reverse strand\n\n"); + PP "-e : [E]rror \n"); + PP " : max error allowed by oligonucleotide\n\n"); + PP "-h : [H]elp - print help\n\n"); + PP "-i : [I]gnore the given taxonomy id.\n"); + PP " taxonomy id are available using the ecofind program.\n"); + PP " see its help typing ecofind -h for more information.\n"); + PP "-k : [K]ingdom mode\n"); + PP " set the kingdom mode\n"); + PP " super kingdom mode by default.\n\n"); + PP "-l : minimum [L]ength\n"); + PP " define the minimum amplication length. \n\n"); + PP "-L : maximum [L]ength\n"); + PP " define the maximum amplicationlength. \n\n"); + PP "-r : [R]estricts the search to the given taxonomy id.\n"); + PP " taxonomy id are available using the ecofind program.\n"); + PP " see its help typing ecofind -h for more information.\n"); PP "\n"); PP "------------------------------------------\n"); PP "datafile : to match the expected format, the database\n"); - PP "has to be formated first by the ecoPCRFormat.py program located.\n"); - PP "in the tools directory.\n"); - PP "ecoPCRFormat.py creates three file types :"); - PP " .sdx : contains the sequences\n"); - PP " .tdx : contains information concerning the taxonomy\n"); - PP " .rdx : contains the taxonomy rank\n\n"); + PP "has to be formated first by the ecoPCRFormat.py program located.\n"); + PP "in the tools directory.\n"); + PP "ecoPCRFormat.py creates three file types :"); + PP " .sdx : contains the sequences\n"); + PP " .tdx : contains information concerning the taxonomy\n"); + PP " .rdx : contains the taxonomy rank\n\n"); PP "ecoPCR needs all the file type. As a result, you have to write the\n"); PP "datafile radical without any extension. For example /database/gbmam\n"); PP "------------------------------------------\n"); - PP "Table result description : \n"); - PP "column 1 : accession number\n"); - PP "column 2 : sequence length\n"); - PP "column 3 : taxonomic id\n"); - PP "column 4 : rank\n"); - PP "column 5 : species taxonomic id\n"); - PP "column 6 : scientific name\n"); - PP "column 7 : genus taxonomic id\n"); - PP "column 8 : genus name\n"); - PP "column 9 : family taxonomic id\n"); - PP "column 10 : family name\n"); - PP "column 11 : super kingdom taxonomic id\n"); - PP "column 11 : super kingdom name\n"); - PP "column 13 : strand (direct or reverse)\n"); - PP "column 14 : first oligonucleotide\n"); - PP "column 15 : number of errors for the first strand\n"); - PP "column 16 : second oligonucleotide\n"); - PP "column 17 : number of errors for the second strand\n"); - PP "column 18 : amplification length\n"); - PP "column 19 : sequence description\n"); + PP "Table result description : \n"); + PP "column 1 : accession number\n"); + PP "column 2 : sequence length\n"); + PP "column 3 : taxonomic id\n"); + PP "column 4 : rank\n"); + PP "column 5 : species taxonomic id\n"); + PP "column 6 : scientific name\n"); + PP "column 7 : genus taxonomic id\n"); + PP "column 8 : genus name\n"); + PP "column 9 : family taxonomic id\n"); + PP "column 10 : family name\n"); + PP "column 11 : super kingdom taxonomic id\n"); + PP "column 11 : super kingdom name\n"); + PP "column 13 : strand (direct or reverse)\n"); + PP "column 14 : first oligonucleotide\n"); + PP "column 15 : number of errors for the first strand\n"); + PP "column 16 : second oligonucleotide\n"); + PP "column 17 : number of errors for the second strand\n"); + PP "column 18 : amplification length\n"); + PP "column 19 : sequence description\n"); PP "------------------------------------------\n"); PP "\n"); @@ -87,7 +87,7 @@ static void PrintHelp() static void ExitUsage(stat) int stat; { - PP "usage: ecoPCR [-1 oligo1] [-2 oligo2] [-l value] [-L value] [-e value] [-r taxid] [-i taxid] [-k] datafile\n"); + PP "usage: ecoPCR [-d database] [-l value] [-L value] [-e value] [-r taxid] [-i taxid] [-k] oligo1 oligo2\n"); PP "type \"ecoPCR -h\" for help\n"); if (stat) @@ -270,7 +270,7 @@ int main(int argc, char **argv) int32_t errflag=0; char kingdom_mode=0; - char *prefix; + char *prefix = NULL; int32_t checkedSequence = 0; int32_t positiveSequence= 0; @@ -300,23 +300,15 @@ int main(int argc, char **argv) int32_t g=0; - while ((carg = getopt(argc, argv, "h1:2:l:L:e:i:r:k")) != -1) { - + while ((carg = getopt(argc, argv, "hd:l:L:e:i:r:k")) != -1) { + switch (carg) { /* -------------------- */ - case '1': /* first primer */ + case 'd': /* database name */ /* -------------------- */ - oligo1 = ECOMALLOC(strlen(optarg)+1, - "Error on oligo 1 allocation"); - strcpy(oligo1,optarg); - break; - - /* -------------------- */ - case '2': /* second primer */ - /* -------------------- */ - oligo2 = ECOMALLOC(strlen(optarg)+1, - "Error on oligo 1 allocation"); - strcpy(oligo2,optarg); + prefix = ECOMALLOC(strlen(optarg)+1, + "Error on prefix allocation"); + strcpy(prefix,optarg); break; /* -------------------- */ @@ -378,17 +370,26 @@ int main(int argc, char **argv) /** * check the path to the database is given as last argument */ - if ((argc -= optind) != 1) - errflag++; - + if ((argc -= optind) == 2) + { + + oligo1 = ECOMALLOC(strlen(argv[optind])+1, + "Error on oligo1 allocation"); + strcpy(oligo1,argv[optind]); + optind++; + oligo2 = ECOMALLOC(strlen(argv[optind])+1, + "Error on oligo1 allocation"); + strcpy(oligo2,argv[optind]); + } + else + errflag++; + if (!oligo1 || !oligo2) errflag++; if (errflag) ExitUsage(errflag); - prefix = argv[optind]; - o1 = buildPattern(oligo1,error_max); o2 = buildPattern(oligo2,error_max); @@ -423,10 +424,10 @@ int main(int argc, char **argv) amplifiatCount = 0; while(seq) - { + { checkedSequence++; /** - * check if current sequence should be ignored + * check if current sequence should be included **/ if ( (r == 0) || (eco_is_taxid_included(taxonomy,