-Use read.getReadGroup()

-Add another filter for read groups for Chris


git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1835 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2009-10-14 18:08:32 +00:00
parent 311ab8da5a
commit 89771fef05
1 changed files with 21 additions and 10 deletions

View File

@ -44,6 +44,8 @@ public class PrintReadsWalker extends ReadWalker<SAMRecord, SAMFileWriter> {
SAMFileWriter outputBamFile = null; SAMFileWriter outputBamFile = null;
@Argument(fullName = "maxReadLength", shortName = "maxRead", doc="Discard reads with length greater than the specified value", required = false) @Argument(fullName = "maxReadLength", shortName = "maxRead", doc="Discard reads with length greater than the specified value", required = false)
Integer maxLength = null; Integer maxLength = null;
@Argument(fullName = "readGroup", shortName = "readGroup", doc="Discard reads not belonging to the specified read group", required = false)
String readGroup = null;
@Argument(fullName = "platform", shortName = "platform", doc="Discard reads not generated by the specified platform", required = false) @Argument(fullName = "platform", shortName = "platform", doc="Discard reads not generated by the specified platform", required = false)
String platform = null; String platform = null;
// E.g. ILLUMINA, 454 // E.g. ILLUMINA, 454
@ -63,19 +65,28 @@ public class PrintReadsWalker extends ReadWalker<SAMRecord, SAMFileWriter> {
* @return true if the read passes the filter, false if it doesn't * @return true if the read passes the filter, false if it doesn't
*/ */
public boolean filter(char[] ref, SAMRecord read) { public boolean filter(char[] ref, SAMRecord read) {
// check the length
if ( maxLength != null && read.getReadLength() > maxLength ) if ( maxLength != null && read.getReadLength() > maxLength )
return false; return false;
if ( platform != null ) {
Object readGroupAttr = read.getAttribute("RG"); // check the read group
if ( readGroupAttr != null ) { if ( readGroup != null ) {
SAMReadGroupRecord readGroup = getToolkit().getSAMFileHeader().getReadGroup(readGroupAttr.toString()); SAMReadGroupRecord myReadGroup = read.getReadGroup();
if ( readGroup != null ) { if ( myReadGroup == null || !readGroup.equals(myReadGroup) )
Object readPlatformAttr = readGroup.getAttribute("PL"); return false;
if ( readPlatformAttr != null )
return readPlatformAttr.toString().toUpperCase().contains(platform);
}
}
} }
// check the platform
if ( platform != null ) {
SAMReadGroupRecord readGroup = read.getReadGroup();
if ( readGroup == null )
return false;
Object readPlatformAttr = readGroup.getAttribute("PL");
if ( readPlatformAttr == null || !readPlatformAttr.toString().toUpperCase().contains(platform))
return false;
}
return true; return true;
} }