diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/PrintReadsWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/PrintReadsWalker.java index 885343d9e..242a294d5 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/PrintReadsWalker.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/PrintReadsWalker.java @@ -1,6 +1,7 @@ package org.broadinstitute.sting.gatk.walkers; import net.sf.samtools.SAMRecord; +import net.sf.samtools.SAMReadGroupRecord; import net.sf.samtools.SAMFileWriter; import net.sf.samtools.SAMFileHeader; import org.broadinstitute.sting.utils.cmdLine.Argument; @@ -49,6 +50,17 @@ public class PrintReadsWalker extends ReadWalker { String outputBamFile = null; @Argument(fullName = "maxReadLength", shortName = "maxRead", doc="Discard reads with length greater than the specified value", required = false) Integer maxLength = null; + @Argument(fullName = "platform", shortName = "platform", doc="Discard reads not generated by the specified platform", required = false) + String platform = null; + // E.g. ILLUMINA, 454 + + /** + * The initialize function. + */ + public void initialize() { + if ( platform != null ) + platform = platform.toUpperCase(); + } /** * The reads filter function. @@ -57,7 +69,20 @@ public class PrintReadsWalker extends ReadWalker { * @return true if the read passes the filter, false if it doesn't */ public boolean filter(char[] ref, SAMRecord read) { - return (maxLength == null || read.getReadLength() <= maxLength); + if ( maxLength != null && read.getReadLength() > maxLength ) + return false; + if ( platform != null ) { + Object readGroupAttr = read.getAttribute("RG"); + if ( readGroupAttr != null ) { + SAMReadGroupRecord readGroup = getToolkit().getEngine().getSAMHeader().getReadGroup(readGroupAttr.toString()); + if ( readGroup != null ) { + Object readPlatformAttr = readGroup.getAttribute("PL"); + if ( readPlatformAttr != null ) + return readPlatformAttr.toString().toUpperCase().contains(platform); + } + } + } + return true; } /**