From 907726c2985cdf9e44217b4da1f7cb2af57cf27d Mon Sep 17 00:00:00 2001 From: Louis Bergelson Date: Wed, 25 Sep 2024 14:24:44 -0400 Subject: [PATCH] Fix for 2bit reference crash when reading the end of the reference (#1586) * Clip requests for sequence to not go over the length of the chromosome. * fixes https://github.com/igvteam/igv/issues/1583 --- src/main/java/org/broad/igv/ucsc/twobit/TwoBitSequence.java | 3 +++ 1 file changed, 3 insertions(+) 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);