From 3248176118d31b1fc5ed812f6e2d4efe5318628c Mon Sep 17 00:00:00 2001 From: ebanks Date: Thu, 2 Apr 2009 16:44:32 +0000 Subject: [PATCH] Die with appropriate error message if we try to read past the end of a chromosome. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@261 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/gatk/iterators/ReferenceIterator.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/iterators/ReferenceIterator.java b/java/src/org/broadinstitute/sting/gatk/iterators/ReferenceIterator.java index 80d34fe3e..520055c29 100755 --- a/java/src/org/broadinstitute/sting/gatk/iterators/ReferenceIterator.java +++ b/java/src/org/broadinstitute/sting/gatk/iterators/ReferenceIterator.java @@ -123,11 +123,16 @@ public class ReferenceIterator implements Iterator { assert seekContigName.equals(currentContig.getName()) : String.format("only works on this contig, but the current %s and sought %s contigs are different!", currentContig.getName(), seekContigName); // we're somewhere on this contig - if ( seekOffset < offset || seekOffset >= currentContig.length() ) { - // bad boy -- can't go backward safely or just beyond the contig length + if ( seekOffset < offset ) { + // bad boy -- can't go backward safely throw new IllegalArgumentException(String.format("Invalid seek to %s from %s, which is usually due to out of order reads%n", new GenomeLoc(currentContig.getName(), seekOffset), new GenomeLoc(currentContig.getName(), offset))); } + else if ( seekOffset >= currentContig.length() ) { + // bad boy -- can't go beyond the contig length + throw new IllegalArgumentException(String.format("Invalid seek to %s, which is beyond the end of the contig%n", + new GenomeLoc(currentContig.getName(), seekOffset+1))); + } else { offset = seekOffset - 1; return next();