diff --git a/java/src/org/broadinstitute/sting/utils/AlignmentUtils.java b/java/src/org/broadinstitute/sting/utils/AlignmentUtils.java index dd4edf521..a9c3f289d 100644 --- a/java/src/org/broadinstitute/sting/utils/AlignmentUtils.java +++ b/java/src/org/broadinstitute/sting/utils/AlignmentUtils.java @@ -258,4 +258,18 @@ public class AlignmentUtils { refLine.append('\n'); return refLine.toString(); } + + /** + * Due to (unfortunate) multiple ways to indicate that read is unmapped allowed by SAM format + * specification, one may need this convenience shortcut. Checks both 'read unmapped' flag and + * alignment reference index/start. + * @param r + * @return + */ + public static boolean isReadUnmapped(final SAMRecord r) { + if ( r.getReadUnmappedFlag() ) return true; + if ( r.getReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX || + r.getAlignmentStart() == SAMRecord.NO_ALIGNMENT_START ) return true; + return false; + } }