added capability for filtering by platform
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1011 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
8f4bc8cb6e
commit
11aa715630
|
|
@ -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<SAMRecord, SAMFileWriter> {
|
|||
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<SAMRecord, SAMFileWriter> {
|
|||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue