diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/fasta/BamToFastqWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/fasta/BamToFastqWalker.java deleted file mode 100755 index b15906a4a..000000000 --- a/java/src/org/broadinstitute/sting/gatk/walkers/fasta/BamToFastqWalker.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2010 The Broad Institute - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR - * THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.broadinstitute.sting.gatk.walkers.fasta; - -import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker; -import org.broadinstitute.sting.gatk.walkers.ReadWalker; -import org.broadinstitute.sting.gatk.walkers.WalkerName; -import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.utils.BaseUtils; -import org.broadinstitute.sting.utils.Utils; -import org.broadinstitute.sting.commandline.Argument; -import org.broadinstitute.sting.commandline.Output; -import net.sf.samtools.SAMRecord; - -import java.io.*; - -/** - * Converts reads from the input BAM file into fastq format, stripping away all alignment information. - * Optionally re-reverses the negative strand alignments using the --re-reverse command-line argument. - */ -@WalkerName("BamToFastq") -public class BamToFastqWalker extends ReadWalker { - @Output - private PrintStream out; - - @Argument(fullName="re_reverse", shortName="reverse", doc="re-reverse bases and quals of reads from the negative strand", required=false) - private Boolean RE_REVERSE = false; - - @Argument(fullName="SQFile", shortName="SQ", doc="Output path for secondary quality map (readName => SAM SQ field)", required=false) - String SQFile = null; - - private PrintWriter sqbw = null; - - public void initialize() { - if ( SQFile != null ) { - try { - sqbw = new PrintWriter(SQFile); - } catch (IOException e) { - throw new RuntimeException("Unable to open sq output file: " + SQFile); - } - } - } - - public Integer map(ReferenceContext ref, SAMRecord read, ReadMetaDataTracker metaDataTracker) { - out.println("@" + read.getReadName()); - if ( !RE_REVERSE || !read.getReadNegativeStrandFlag() ) { - out.println(read.getReadString()); - out.println("+"); - out.println(read.getBaseQualityString()); - } else { - out.println(BaseUtils.simpleReverseComplement(read.getReadString())); - out.println("+"); - out.println(Utils.reverse(read.getBaseQualityString())); - } - - if ( sqbw != null ) { - byte[] sqs = (byte[])read.getAttribute("SQ"); - if ( sqs != null ) { - sqbw.print(read.getReadName() + "\t" + "SQ:H:"); - for ( byte sq : sqs ) { - sqbw.printf("%02X", sq); - } - sqbw.println(); - } - } - - return 1; - } - - public Integer reduceInit() { - return 0; - } - - public Integer reduce(Integer value, Integer sum) { - return value + sum; - } - - public void onTraversalDone(Integer sum) { - if ( sqbw != null ) - sqbw.close(); - logger.info("Number of reads converted: " + sum); - } -} \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/playground/tools/BamToFastq.java b/java/src/org/broadinstitute/sting/playground/tools/BamToFastq.java deleted file mode 100644 index 7abc5d160..000000000 --- a/java/src/org/broadinstitute/sting/playground/tools/BamToFastq.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.broadinstitute.sting.playground.tools; - -import net.sf.picard.cmdline.CommandLineProgram; -import net.sf.picard.cmdline.Usage; -import net.sf.picard.cmdline.Option; -import net.sf.samtools.SAMFileReader; -import net.sf.samtools.SAMRecord; - -import java.io.*; - -import org.broadinstitute.sting.utils.BaseUtils; -import org.broadinstitute.sting.utils.Utils; - -/** - * Created by IntelliJ IDEA. - * User: asivache - * Date: Aug 12, 2009 - * Time: 3:24:46 PM - * To change this template use File | Settings | File Templates. - */ -public class BamToFastq extends CommandLineProgram { - @Usage(programVersion="1.0") public String USAGE = "Extracts read sequences and qualities from the input sam/bam file and wirtes them into "+ - "the output file in fastq format. In the RC mode (default is True), if the read is aligned and the alignment is to the reverse strand on the genome, "+ - "the read's sequence from input sam file will be reverse-complemented prior to writing it to fastq in order restore correctly "+ - "the original read sequence as it was generated by the sequencer."; - @Option(shortName="I", doc="Input file (bam or sam) to extract reads from. If not specified, reads from stdin.", - optional=true) public File IN = null; - @Option(shortName="O",doc="Output file (fastq). If not specified, output is printed to stdout.", - optional=true) public File OUT = null; - @Option(shortName="RC", doc="re-reverse bases and quals of reads aligned to the negative strand before writing them to fastq", optional=true) - public Boolean RE_REVERSE = true; - - public static void main(final String[] argv) { - System.exit(new BamToFastq().instanceMain(argv)); - } - - protected int doWork() { - - - InputStream ins = null; - if ( IN == null ) ins = System.in; - else { - try { - ins = new FileInputStream(IN); - } catch ( FileNotFoundException ie ) { - System.out.println("Failed to open input file "+IN+": "+ie.getCause()); - return 1; - } - } - - SAMFileReader inReader = new SAMFileReader(ins); - PrintStream out = null; - if ( OUT == null ) out = System.out; - else { - try { - out = new PrintStream(OUT); - } catch ( FileNotFoundException ie ) { - System.out.println("Failed to open output file "+OUT+": "+ie.getCause()); - return 1; - } - } - - for (SAMRecord read : inReader ) { - out.println("@" + read.getReadName()); - if ( read.getReadUnmappedFlag() || !RE_REVERSE || !read.getReadNegativeStrandFlag() ) { - out.println(read.getReadString()); - out.println('+'); - out.println(read.getBaseQualityString()); - } else { - out.println(BaseUtils.simpleReverseComplement(read.getReadString())); - out.println('+'); - out.println(Utils.reverse(read.getBaseQualityString())); - } - } - inReader.close(); - out.close(); - - return 0; - } - - -} diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/fasta/BamToFastqIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/fasta/BamToFastqIntegrationTest.java deleted file mode 100755 index 48c0215cc..000000000 --- a/java/test/org/broadinstitute/sting/gatk/walkers/fasta/BamToFastqIntegrationTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.broadinstitute.sting.gatk.walkers.fasta; - -import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; - -import java.util.Arrays; - -public class BamToFastqIntegrationTest extends WalkerTest { - @Test - public void testIntervals() { - - WalkerTestSpec spec1 = new WalkerTestSpec( - "-T BamToFastq -R " + b36KGReference + " -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,100-10,000,500;1:10,100,000-10,101,000;1:10,900,000-10,900,001 -o %s", - 1, - Arrays.asList("49431d567524d6fd32a569504b25f212")); - executeTest("testBamToFasta", spec1); - - WalkerTestSpec spec2 = new WalkerTestSpec( - "-T BamToFastq -reverse -R " + b36KGReference + " -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,100-10,000,500;1:10,100,000-10,101,000;1:10,900,000-10,900,001 -o %s", - 1, - Arrays.asList("f3a4a39d36270136c12bb1315fdb7dff")); - executeTest("testBamToFastaReverse", spec2); - } -}