]> git.donarmstrong.com Git - fastq-tools.git/blob - src/fastq-grep.c
initial work on some useful fastq tools
[fastq-tools.git] / src / fastq-grep.c
1
2
3 /* 
4  * fastq-grep: regular expression searches of the sequences within a fastq file
5  *
6  * Febuary 2011 / Daniel Jones <dcjones@cs.washington.edu> 
7  *
8  */
9
10
11 #include <stdio.h>
12 #include <string.h>
13 #include <getopt.h>
14 #include <zlib.h>
15 #include <pcre.h>
16
17 #include "kseq.h"
18 KSEQ_INIT(gzFile, gzread)
19
20
21 void print_help()
22 {
23     fprintf( stderr, 
24 "fastq-grep [OPTION]... PATTERN [FILE]...\n"
25 "Search for PATTERN in the read sequence in each FILE or standard input.\n"
26 "PATTERN, by default, is a perl compatible regular expression."
27     );
28
29 }
30
31 static int invert_flag;
32 static int help_flag;
33
34 int main(int argc, char* argv[])
35 {
36
37     int opt;
38     int opt_idx;
39
40     static struct option long_options[] =
41         { 
42           {"help", no_argument, &help_flag, 1},
43           {"invert-match", no_argument, &invert_flag, 1},
44           {0, 0, 0, 0}
45         };
46
47     while (1) {
48         opt = getopt_long(argc, argv, "hv", long_options, &opt_idx);
49
50         if( opt == -1 ) break;
51
52         switch (opt) {
53             case 0:
54                 if (long_options[opt_idx].flag != 0) break;
55                 if (optarg) {
56                     /* TODO */
57                 }
58                 break;
59
60             case 'h':
61                 help_flag = 1;
62                 break;
63
64             case 'v':
65                 invert_flag = 1;
66                 break;
67
68             default:
69                 abort();
70         }
71     }
72
73     if (help_flag) {
74         print_help();
75         return 0;
76     }
77
78     /* TODO */
79
80     return 0;
81 }
82
83
84