1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.utgenome.shell;
26
27 import java.io.BufferedReader;
28 import java.io.BufferedWriter;
29 import java.io.FileReader;
30 import java.io.FileWriter;
31 import java.io.InputStreamReader;
32 import java.io.OutputStreamWriter;
33
34 import org.utgenome.format.illumina.QSeqToFASTQ;
35 import org.xerial.util.opt.Argument;
36 import org.xerial.util.opt.Option;
37
38 public class QSeqToFastq extends UTGBShellCommand {
39
40 @Option(symbol = "g", longName = "readgroup", varName = "RG", description = "read group name (e.g., HG0001SE:L3)")
41 private String readGroup;
42
43 @Argument(index = 0, name = "input")
44 private String input = "-";
45 @Argument(index = 1, name = "output")
46 private String output = "-";
47
48 @Option(longName = "nofilter", description = "do not apply quality filter (default: false)")
49 private boolean disableQualityFilter = false;
50
51 @Override
52 public void execute(String[] args) throws Exception {
53
54 QSeqToFASTQ converter = readGroup == null ? new QSeqToFASTQ(disableQualityFilter) : new QSeqToFASTQ(readGroup, disableQualityFilter);
55
56 boolean closeIn = false;
57 boolean closeOut = false;
58
59 BufferedReader inputReader = null;
60 BufferedWriter outputWriter = null;
61
62 try {
63 if ("-".equals(input)) {
64 inputReader = new BufferedReader(new InputStreamReader(System.in));
65 }
66 else {
67 inputReader = new BufferedReader(new FileReader(input));
68 closeIn = true;
69 }
70
71 if ("-".equals(output)) {
72 outputWriter = new BufferedWriter(new OutputStreamWriter(System.out));
73 }
74 else {
75 outputWriter = new BufferedWriter(new FileWriter(output));
76 closeOut = true;
77 }
78
79 converter.convert(inputReader, outputWriter);
80 }
81 finally {
82 if (closeIn && inputReader != null)
83 inputReader.close();
84
85 if (closeOut && outputWriter != null)
86 outputWriter.close();
87 }
88 }
89
90 @Override
91 public String getOneLinerDescription() {
92 return "convert Illumina's qseq format into FASTQ";
93 }
94
95 @Override
96 public String name() {
97 return "qseq2fastq";
98 }
99
100 }