annotate src/trim_single.c @ 4:c70137414dcd draft

sickle v1.33
author nikhil-joshi
date Wed, 23 Jul 2014 18:35:10 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
1 #include <assert.h>
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
2 #include <ctype.h>
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
3 #include <stdlib.h>
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
4 #include <zlib.h>
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
5 #include <stdio.h>
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
6 #include <getopt.h>
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
7 #include "sickle.h"
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
8 #include "kseq.h"
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
9 #include "print_record.h"
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
10
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
11 __KS_GETC(gzread, BUFFER_SIZE)
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
12 __KS_GETUNTIL(gzread, BUFFER_SIZE)
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
13 __KSEQ_READ
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
14
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
15 int single_qual_threshold = 20;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
16 int single_length_threshold = 20;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
17
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
18 static struct option single_long_options[] = {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
19 {"fastq-file", required_argument, 0, 'f'},
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
20 {"output-file", required_argument, 0, 'o'},
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
21 {"qual-type", required_argument, 0, 't'},
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
22 {"qual-threshold", optional_argument, 0, 'q'},
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
23 {"length-threshold", optional_argument, 0, 'l'},
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
24 {"no-fiveprime", optional_argument, 0, 'x'},
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
25 {"discard-n", optional_argument, 0, 'n'},
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
26 {"gzip-output", optional_argument, 0, 'g'},
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
27 {"quiet", optional_argument, 0, 'z'},
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
28 {GETOPT_HELP_OPTION_DECL},
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
29 {GETOPT_VERSION_OPTION_DECL},
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
30 {NULL, 0, NULL, 0}
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
31 };
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
32
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
33 void single_usage(int status, char *msg) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
34
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
35 fprintf(stderr, "\nUsage: %s se [options] -f <fastq sequence file> -t <quality type> -o <trimmed fastq file>\n\
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
36 \n\
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
37 Options:\n\
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
38 -f, --fastq-file, Input fastq file (required)\n\
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
39 -t, --qual-type, Type of quality values (solexa (CASAVA < 1.3), illumina (CASAVA 1.3 to 1.7), sanger (which is CASAVA >= 1.8)) (required)\n\
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
40 -o, --output-file, Output trimmed fastq file (required)\n", PROGRAM_NAME);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
41
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
42 fprintf(stderr, "-q, --qual-threshold, Threshold for trimming based on average quality in a window. Default 20.\n\
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
43 -l, --length-threshold, Threshold to keep a read based on length after trimming. Default 20.\n\
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
44 -x, --no-fiveprime, Don't do five prime trimming.\n\
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
45 -n, --trunc-n, Truncate sequences at position of first N.\n\
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
46 -g, --gzip-output, Output gzipped files.\n\
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
47 --quiet, Don't print out any trimming information\n\
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
48 --help, display this help and exit\n\
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
49 --version, output version information and exit\n\n");
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
50
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
51 if (msg) fprintf(stderr, "%s\n\n", msg);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
52 exit(status);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
53 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
54
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
55 int single_main(int argc, char *argv[]) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
56
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
57 gzFile se = NULL;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
58 kseq_t *fqrec;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
59 int l;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
60 FILE *outfile = NULL;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
61 gzFile outfile_gzip = NULL;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
62 int debug = 0;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
63 int optc;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
64 extern char *optarg;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
65 int qualtype = -1;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
66 cutsites *p1cut;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
67 char *outfn = NULL;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
68 char *infn = NULL;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
69 int kept = 0;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
70 int discard = 0;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
71 int quiet = 0;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
72 int no_fiveprime = 0;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
73 int trunc_n = 0;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
74 int gzip_output = 0;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
75
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
76 while (1) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
77 int option_index = 0;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
78 optc = getopt_long(argc, argv, "df:t:o:q:l:zxng", single_long_options, &option_index);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
79
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
80 if (optc == -1)
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
81 break;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
82
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
83 switch (optc) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
84 if (single_long_options[option_index].flag != 0)
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
85 break;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
86
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
87 case 'f':
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
88 infn = (char *) malloc(strlen(optarg) + 1);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
89 strcpy(infn, optarg);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
90 break;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
91
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
92 case 't':
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
93 if (!strcmp(optarg, "illumina"))
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
94 qualtype = ILLUMINA;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
95 else if (!strcmp(optarg, "solexa"))
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
96 qualtype = SOLEXA;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
97 else if (!strcmp(optarg, "sanger"))
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
98 qualtype = SANGER;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
99 else {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
100 fprintf(stderr, "Error: Quality type '%s' is not a valid type.\n", optarg);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
101 return EXIT_FAILURE;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
102 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
103 break;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
104
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
105 case 'o':
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
106 outfn = (char *) malloc(strlen(optarg) + 1);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
107 strcpy(outfn, optarg);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
108 break;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
109
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
110 case 'q':
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
111 single_qual_threshold = atoi(optarg);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
112 if (single_qual_threshold < 0) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
113 fprintf(stderr, "Quality threshold must be >= 0\n");
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
114 return EXIT_FAILURE;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
115 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
116 break;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
117
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
118 case 'l':
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
119 single_length_threshold = atoi(optarg);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
120 if (single_length_threshold < 0) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
121 fprintf(stderr, "Length threshold must be >= 0\n");
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
122 return EXIT_FAILURE;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
123 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
124 break;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
125
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
126 case 'x':
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
127 no_fiveprime = 1;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
128 break;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
129
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
130 case 'n':
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
131 trunc_n = 1;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
132 break;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
133
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
134 case 'g':
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
135 gzip_output = 1;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
136 break;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
137
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
138 case 'z':
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
139 quiet = 1;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
140 break;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
141
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
142 case 'd':
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
143 debug = 1;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
144 break;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
145
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
146 case_GETOPT_HELP_CHAR(single_usage)
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
147 case_GETOPT_VERSION_CHAR(PROGRAM_NAME, VERSION, AUTHORS);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
148
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
149 case '?':
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
150 single_usage(EXIT_FAILURE, NULL);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
151 break;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
152
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
153 default:
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
154 single_usage(EXIT_FAILURE, NULL);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
155 break;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
156 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
157 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
158
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
159
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
160 if (qualtype == -1 || !infn || !outfn) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
161 single_usage(EXIT_FAILURE, "****Error: Must have quality type, input file, and output file.");
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
162 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
163
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
164 if (!strcmp(infn, outfn)) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
165 fprintf(stderr, "****Error: Input file is same as output file.\n\n");
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
166 return EXIT_FAILURE;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
167 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
168
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
169 se = gzopen(infn, "r");
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
170 if (!se) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
171 fprintf(stderr, "****Error: Could not open input file '%s'.\n\n", infn);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
172 return EXIT_FAILURE;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
173 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
174
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
175 if (!gzip_output) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
176 outfile = fopen(outfn, "w");
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
177 if (!outfile) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
178 fprintf(stderr, "****Error: Could not open output file '%s'.\n\n", outfn);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
179 return EXIT_FAILURE;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
180 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
181 } else {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
182 outfile_gzip = gzopen(outfn, "w");
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
183 if (!outfile_gzip) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
184 fprintf(stderr, "****Error: Could not open output file '%s'.\n\n", outfn);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
185 return EXIT_FAILURE;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
186 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
187 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
188
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
189
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
190 fqrec = kseq_init(se);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
191
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
192 while ((l = kseq_read(fqrec)) >= 0) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
193
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
194 p1cut = sliding_window(fqrec, qualtype, single_length_threshold, single_qual_threshold, no_fiveprime, trunc_n, debug);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
195
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
196 if (debug) printf("P1cut: %d,%d\n", p1cut->five_prime_cut, p1cut->three_prime_cut);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
197
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
198 /* if sequence quality and length pass filter then output record, else discard */
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
199 if (p1cut->three_prime_cut >= 0) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
200 if (!gzip_output) {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
201 /* This print statement prints out the sequence string starting from the 5' cut */
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
202 /* and then only prints out to the 3' cut, however, we need to adjust the 3' cut */
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
203 /* by subtracting the 5' cut because the 3' cut was calculated on the original sequence */
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
204
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
205 print_record (outfile, fqrec, p1cut);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
206 } else {
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
207 print_record_gzip (outfile_gzip, fqrec, p1cut);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
208 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
209
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
210 kept++;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
211 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
212
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
213 else discard++;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
214
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
215 free(p1cut);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
216 }
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
217
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
218 if (!quiet) fprintf(stdout, "\nFastQ records kept: %d\nFastQ records discarded: %d\n\n", kept, discard);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
219
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
220 kseq_destroy(fqrec);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
221 gzclose(se);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
222 if (!gzip_output) fclose(outfile);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
223 else gzclose(outfile_gzip);
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
224
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
225 return EXIT_SUCCESS;
c70137414dcd sickle v1.33
nikhil-joshi
parents:
diff changeset
226 }