diff --git a/src/main/java/org/broad/igv/ucsc/twobit/TwoBitSequence.java b/src/main/java/org/broad/igv/ucsc/twobit/TwoBitSequence.java index d491d997f..27368ad83 100644 --- a/src/main/java/org/broad/igv/ucsc/twobit/TwoBitSequence.java +++ b/src/main/java/org/broad/igv/ucsc/twobit/TwoBitSequence.java @@ -133,6 +133,9 @@ public byte[] readSequence(String seqName, int regionStart, int regionEnd) { throw new RuntimeException("regionStart cannot be less than 0"); } + //don't run off the end of the genome + regionEnd = Math.min(record.getDnaSize(), regionEnd); + Queue nBlocks = _getOverlappingBlocks(regionStart, regionEnd, record.nBlocks); Queue maskBlocks = _getOverlappingBlocks(regionStart, regionEnd, record.maskBlocks);