static boolean passesFilter ( SAMRecord record , Filter filter , String referenceName ) { // If we are looking for only mapped or only unmapped reads then we will use // the UnmappedFlag to decide if this read should be rejected. if ( filter == Filter . UNMAPPED_ONLY && ! record . getReadUnmappedFlag ( ) ) { return false ; } if ( filter == Filter . MAPPED_ONLY && record . getReadUnmappedFlag ( ) ) { return false ; } // If we are looking for mapped reads, then we check the reference name // of the read matches the one we are looking for. final boolean referenceNameMismatch = referenceName != null && ! referenceName . isEmpty ( ) && ! referenceName . equals ( record . getReferenceName ( ) ) ; // Note that unmapped mate pair of mapped read will have a reference // name set to the reference of its mapped mate. if ( ( filter == Filter . MAPPED_ONLY || filter == Filter . MAPPED_AND_UNMAPPED ) && referenceNameMismatch ) { return false ; } return true ; }
Checks if the record matches our filter .