annotate src/trim_single.c @ 9:7939dd56c4b4 draft

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