View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2010 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-core Project
18  //
19  // FastqToSilkReader.java
20  // Since: 2010/07/08
21  //
22  //--------------------------------------
23  package org.utgenome.format.fastq;
24  
25  import java.io.IOException;
26  import java.io.Reader;
27  import java.io.Writer;
28  
29  import org.utgenome.format.FormatConversionReader;
30  import org.xerial.silk.SilkWriter;
31  
32  /**
33   * Read the FASTQ file input from the given reader as if it were a Silk
34   * 
35   * @author leo
36   * 
37   */
38  public class FastqToSilkReader extends FormatConversionReader {
39  
40  	public FastqToSilkReader(Reader fastqInput) throws IOException {
41  		super(fastqInput, new PipeConsumer() {
42  			@Override
43  			public void consume(Reader in, Writer out) throws Exception {
44  				FastqReader reader = new FastqReader(in);
45  				SilkWriter silk = new SilkWriter(out);
46  				for (FastqRead read = null; (read = reader.next()) != null;) {
47  					read.toSilk(silk);
48  				}
49  				silk.flush();
50  			}
51  		});
52  
53  	}
54  }