X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Ffastq-match.c;h=bd040a6cf7df9535dc3bd1e1924f4d7157476d7a;hb=bcdcb70445c167236311be383233e8dff4c9d54c;hp=09da29ba5eefa1cdf312c83b48bc96525ad426ab;hpb=40ab4c0cde1bfee1616777995998b0cbc5ffc741;p=fastq-tools.git diff --git a/src/fastq-match.c b/src/fastq-match.c index 09da29b..bd040a6 100644 --- a/src/fastq-match.c +++ b/src/fastq-match.c @@ -27,26 +27,23 @@ #endif -static int help_flag; +static const char* prog_name = "fastq-match"; void print_help() { - fprintf(stderr, + fprintf(stdout, "fastq-match [OPTION]... QUERY [FILE]...\n" "Perform Smith-Waterman local alignment of a query sequence\n" "against each sequence in a fastq file.\n\n" "Options:\n" " -h, --help print this message\n" +" -V, --version output version information and exit\n" ); } - - -void fastq_match(FILE* fin, FILE* fout, - sw_t* sw, - unsigned char* query, int n) +void fastq_match(FILE* fin, FILE* fout, sw_t* sw) { int score; @@ -80,22 +77,19 @@ int main(int argc, char* argv[]) FILE* fin; - help_flag = 0; - int opt; int opt_idx; static struct option long_options[] = { - {"help", no_argument, &help_flag, 1}, - {"gap-init", required_argument, NULL, 0}, - {"gap-extend", required_argument, NULL, 0}, + {"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, 'V'}, {0, 0, 0, 0} }; while (1) { - opt = getopt_long(argc, argv, "h", long_options, &opt_idx); + opt = getopt_long(argc, argv, "hV", long_options, &opt_idx); if (opt == -1) break; @@ -107,8 +101,12 @@ int main(int argc, char* argv[]) break; case 'h': - help_flag = 1; - break; + print_help(); + return 0; + + case 'V': + print_version(stdout, prog_name); + return 0; case '?': return 1; @@ -118,10 +116,6 @@ int main(int argc, char* argv[]) } } - if (help_flag) { - print_help(); - return 0; - } if (optind >= argc) { fprintf(stderr, "A query sequence must be specified.\n"); @@ -135,7 +129,7 @@ int main(int argc, char* argv[]) sw = fastq_alloc_sw(query, query_len); if (optind >= argc || (argc - optind == 1 && strcmp(argv[optind],"-") == 0)) { - fastq_match(stdin, stdout, sw, query, query_len); + fastq_match(stdin, stdout, sw); } else { for (; optind < argc; optind++) { @@ -145,7 +139,7 @@ int main(int argc, char* argv[]) continue; } - fastq_match(fin, stdout, sw, query, query_len); + fastq_match(fin, stdout, sw); } }