From cac04a407a7039428d5f6ab121b34ea20fabc1b9 Mon Sep 17 00:00:00 2001 From: hanna Date: Wed, 22 Jul 2009 21:19:24 +0000 Subject: [PATCH] For Manny: filter out reads where the the ref index == NO_ALIGNMENT_REFERENCE_INDEX but the alignment start != NO_ALIGNMENT_START. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1295 348d0f76-0448-11de-a6fe-93d51630548a --- .../broadinstitute/sting/utils/sam/SAMReadValidator.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/java/src/org/broadinstitute/sting/utils/sam/SAMReadValidator.java b/java/src/org/broadinstitute/sting/utils/sam/SAMReadValidator.java index a647aa64a..b2e590a00 100644 --- a/java/src/org/broadinstitute/sting/utils/sam/SAMReadValidator.java +++ b/java/src/org/broadinstitute/sting/utils/sam/SAMReadValidator.java @@ -70,9 +70,16 @@ public class SAMReadValidator { throw new SAMReadValidationException("Alignment ends prior to its beginning"); } + /** + * Check to ensure that the alignment makes sense based on the contents of the header. + * @param header The SAM file header. + * @param read The read to verify. + */ private static void checkAlignmentDisagreesWithHeader( SAMFileHeader header, SAMRecord read ) { + if( read.getReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX && read.getAlignmentStart() != SAMRecord.NO_ALIGNMENT_START ) + throw new SAMReadValidationException("Read is aligned to nonexistent contig"); SAMSequenceRecord contigHeader = header.getSequence( read.getReferenceIndex() ); - if( !read.getReadUnmappedFlag() && read.getAlignmentStart() > contigHeader.getSequenceLength() ) + if( read.getReadUnmappedFlag() && read.getAlignmentStart() > contigHeader.getSequenceLength() ) throw new SAMReadValidationException("Read is aligned to a point after the end of the contig"); }