Added a walker to convert a bam file to fastq format (including the option to re-reverse the negative strand reads).
Picard has such a tool but it is geared towards their pipeline and requires intimate knowledge of the lanes/flowcells,etc. This is just easy. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1413 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
d101c20b30
commit
43f63b7530
|
|
@ -0,0 +1,43 @@
|
|||
package org.broadinstitute.sting.playground.gatk.walkers.fasta;
|
||||
|
||||
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
|
||||
import org.broadinstitute.sting.gatk.walkers.WalkerName;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.cmdLine.Argument;
|
||||
import net.sf.samtools.SAMRecord;
|
||||
|
||||
// create a fastq file from a bam file
|
||||
|
||||
@WalkerName("BamToFastq")
|
||||
public class BamToFastqWalker extends ReadWalker<Integer, Integer> {
|
||||
|
||||
@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;
|
||||
|
||||
public Integer map(char[] ref, SAMRecord read) {
|
||||
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(BaseUtils.simpleReverseComplement(read.getBaseQualityString()));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public Integer reduceInit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Integer reduce(Integer value, Integer sum) {
|
||||
return value + sum;
|
||||
}
|
||||
|
||||
public void onTraversalDone(Integer sum) {
|
||||
logger.info("Number of reads converted: " + sum);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue