View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2008 utgenome.org
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *--------------------------------------------------------------------------*/
16  //--------------------------------------
17  // utgb-shell Project
18  //
19  // Illumina2Fastq.java
20  // Since: Jun 14, 2010
21  //
22  // $URL$ 
23  // $Author$
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.Seq2Fastq;
35  import org.xerial.util.opt.Argument;
36  
37  public class Illumina2Fastq extends UTGBShellCommand {
38  
39  	/**
40  	 * 
41  	 */
42  	@Argument(index = 0)
43  	private String in = "-";
44  	@Argument(index = 1)
45  	private String out = "-";
46  
47  	@Override
48  	public void execute(String[] args) throws Exception {
49  
50  		BufferedReader input = null;
51  		BufferedWriter output = null;
52  		if ("-".equals(in)) {
53  			input = new BufferedReader(new InputStreamReader(System.in));
54  		}
55  		else {
56  			input = new BufferedReader(new FileReader(in));
57  		}
58  
59  		if ("-".equals(out)) {
60  			output = new BufferedWriter(new OutputStreamWriter(System.out));
61  		}
62  		else {
63  			output = new BufferedWriter(new FileWriter(out));
64  		}
65  
66  		Seq2Fastq.convert(input, output);
67  
68  		output.flush();
69  
70  	}
71  
72  	@Override
73  	public String getOneLinerDescription() {
74  		return "convert Illumina's raw read (*_sequence.txt) into fastq format";
75  	}
76  
77  	@Override
78  	public String name() {
79  		return "illumina2fastq";
80  	}
81  
82  }