-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:
parent
311ab8da5a
commit
89771fef05
|
|
@ -44,6 +44,8 @@ public class PrintReadsWalker extends ReadWalker<SAMRecord, SAMFileWriter> {
|
|||
SAMFileWriter outputBamFile = null;
|
||||
@Argument(fullName = "maxReadLength", shortName = "maxRead", doc="Discard reads with length greater than the specified value", required = false)
|
||||
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)
|
||||
String platform = null;
|
||||
// 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
|
||||
*/
|
||||
public boolean filter(char[] ref, SAMRecord read) {
|
||||
// check the length
|
||||
if ( maxLength != null && read.getReadLength() > maxLength )
|
||||
return false;
|
||||
if ( platform != null ) {
|
||||
Object readGroupAttr = read.getAttribute("RG");
|
||||
if ( readGroupAttr != null ) {
|
||||
SAMReadGroupRecord readGroup = getToolkit().getSAMFileHeader().getReadGroup(readGroupAttr.toString());
|
||||
if ( readGroup != null ) {
|
||||
Object readPlatformAttr = readGroup.getAttribute("PL");
|
||||
if ( readPlatformAttr != null )
|
||||
return readPlatformAttr.toString().toUpperCase().contains(platform);
|
||||
}
|
||||
}
|
||||
|
||||
// check the read group
|
||||
if ( readGroup != null ) {
|
||||
SAMReadGroupRecord myReadGroup = read.getReadGroup();
|
||||
if ( myReadGroup == null || !readGroup.equals(myReadGroup) )
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue