diff --git a/java/src/org/broadinstitute/sting/utils/interval/IntervalUtils.java b/java/src/org/broadinstitute/sting/utils/interval/IntervalUtils.java index 7b10ccf86..4197982c9 100644 --- a/java/src/org/broadinstitute/sting/utils/interval/IntervalUtils.java +++ b/java/src/org/broadinstitute/sting/utils/interval/IntervalUtils.java @@ -113,6 +113,10 @@ public class IntervalUtils { else iTwo++; } + //if we have an empty list, throw an exception. If they specified intersection and there are no items, this is bad. + if (retList == null || retList.size() == 0) + throw new UserException.BadInput("The INTERSECTION of your -BTI and -L options produced no intervals."); + // we don't need to add the rest of remaining locations, since we know they don't overlap. return what we have return retList; } diff --git a/java/test/org/broadinstitute/sting/utils/interval/IntervalUtilsUnitTest.java b/java/test/org/broadinstitute/sting/utils/interval/IntervalUtilsUnitTest.java index 637b4571c..da1913e9a 100644 --- a/java/test/org/broadinstitute/sting/utils/interval/IntervalUtilsUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/interval/IntervalUtilsUnitTest.java @@ -31,7 +31,7 @@ public class IntervalUtilsUnitTest extends BaseTest { genomeLocParser = new GenomeLocParser(seq); } - @Test + @Test(expectedExceptions=UserException.class) public void testMergeListsBySetOperatorNoOverlap() { // a couple of lists we'll use for the testing List listEveryTwoFromOne = new ArrayList();