Mercurial > repos > xilinxu > xilinxu
comparison fastx_toolkit-0.0.6/src/fastq_quality_converter/fastq_quality_converter.c @ 3:997f5136985f draft default tip
Uploaded
author | xilinxu |
---|---|
date | Thu, 14 Aug 2014 04:52:17 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:dfe9332138cf | 3:997f5136985f |
---|---|
1 /* | |
2 FASTX-toolkit - FASTA/FASTQ preprocessing tools. | |
3 Copyright (C) 2009 A. Gordon (gordon@cshl.edu) | |
4 | |
5 This program is free software: you can redistribute it and/or modify | |
6 it under the terms of the GNU Affero General Public License as | |
7 published by the Free Software Foundation, either version 3 of the | |
8 License, or (at your option) any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU Affero General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Affero General Public License | |
16 along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 */ | |
18 #include <limits.h> | |
19 #include <stdio.h> | |
20 #include <stdlib.h> | |
21 #include <string.h> | |
22 #include <getopt.h> | |
23 #include <errno.h> | |
24 #include <err.h> | |
25 | |
26 #include <config.h> | |
27 | |
28 #include "fastx.h" | |
29 #include "fastx_args.h" | |
30 | |
31 const char* usage= | |
32 "usage: fastq_quality_converter [-h] [-a] [-n] [-z] [-i INFILE] [-f OUTFILE]\n" \ | |
33 "\n" \ | |
34 "version " VERSION "\n" \ | |
35 " [-h] = This helpful help screen.\n" \ | |
36 " [-a] = Output ASCII quality scores (default).\n" \ | |
37 " [-n] = Output numeric quality scores.\n" \ | |
38 " [-z] = Compress output with GZIP.\n" \ | |
39 " [-i INFILE] = FASTA/Q input file. default is STDIN.\n" \ | |
40 " [-o OUTFILE] = FASTA output file. default is STDOUT.\n" \ | |
41 "\n"; | |
42 | |
43 FASTX fastx; | |
44 int flag_output_ascii = 1; | |
45 | |
46 int parse_program_args(int __attribute__((unused)) optind, int optc, char __attribute__((unused)) *optarg) | |
47 { | |
48 switch(optc) { | |
49 case 'a': //this is the default, nothing to change | |
50 break; | |
51 | |
52 case 'n': | |
53 flag_output_ascii = 0 ; | |
54 break; | |
55 default: | |
56 errx(1, __FILE__ ":%d: Unknown argument (%c)", __LINE__, optc ) ; | |
57 } | |
58 return 1; | |
59 } | |
60 | |
61 | |
62 int main(int argc, char* argv[]) | |
63 { | |
64 fastx_parse_cmdline(argc, argv, "an", parse_program_args); | |
65 | |
66 fastx_init_reader(&fastx, get_input_filename(), | |
67 FASTQ_ONLY, ALLOW_N, REQUIRE_UPPERCASE); | |
68 | |
69 fastx_init_writer(&fastx, get_output_filename(), | |
70 flag_output_ascii ? OUTPUT_FASTQ_ASCII_QUAL : OUTPUT_FASTQ_NUMERIC_QUAL, | |
71 compress_output_flag()); | |
72 | |
73 while ( fastx_read_next_record(&fastx) ) { | |
74 fastx_write_record(&fastx); | |
75 } | |
76 | |
77 //Print verbose report | |
78 if ( verbose_flag() ) { | |
79 fprintf(get_report_file(), "Input: %zu reads.\n", num_input_reads(&fastx) ) ; | |
80 fprintf(get_report_file(), "Output: %zu reads.\n", num_output_reads(&fastx) ) ; | |
81 } | |
82 return 0; | |
83 } |