@@ -39,7 +39,7 @@ export default class TabixIndex extends IndexFile {
3939 if ( ! idx ) {
4040 return - 1
4141 }
42- return indexData . indices [ refId ] . stats ?. lineCount ?? - 1
42+ return idx . stats ?. lineCount ?? - 1
4343 }
4444
4545 // fetch and parse the index
@@ -181,11 +181,12 @@ export default class TabixIndex extends IndexFile {
181181 return [ ]
182182 }
183183
184+ const linearIndex = ba . linearIndex ?? [ ]
184185 const minOffset =
185- ba . linearIndex . length > 0
186- ? ba . linearIndex [
187- min >> TAD_LIDX_SHIFT >= ba . linearIndex . length
188- ? ba . linearIndex . length - 1
186+ linearIndex . length > 0
187+ ? linearIndex [
188+ min >> TAD_LIDX_SHIFT >= linearIndex . length
189+ ? linearIndex . length - 1
189190 : min >> TAD_LIDX_SHIFT
190191 ]
191192 : new VirtualOffset ( 0 , 0 )
@@ -201,8 +202,9 @@ export default class TabixIndex extends IndexFile {
201202 // Find chunks in overlapping bins. Leaf bins (< 4681) are not pruned
202203 for ( const [ start , end ] of overlappingBins ) {
203204 for ( let bin = start ; bin <= end ; bin ++ ) {
204- if ( ba . binIndex [ bin ] ) {
205- for ( const c of ba . binIndex [ bin ] ) {
205+ const binChunks = ba . binIndex [ bin ]
206+ if ( binChunks ) {
207+ for ( const c of binChunks ) {
206208 chunks . push ( new Chunk ( c . minv , c . maxv , bin ) )
207209 }
208210 }
@@ -211,12 +213,12 @@ export default class TabixIndex extends IndexFile {
211213
212214 // Use the linear index to find minimum file position of chunks that could
213215 // contain alignments in the region
214- const nintv = ba . linearIndex . length
216+ const nintv = linearIndex . length
215217 let lowest : VirtualOffset | undefined
216218 const minLin = Math . min ( min >> 14 , nintv - 1 )
217219 const maxLin = Math . min ( max >> 14 , nintv - 1 )
218220 for ( let i = minLin ; i <= maxLin ; ++ i ) {
219- const vp = ba . linearIndex [ i ]
221+ const vp = linearIndex [ i ]
220222 if ( vp && ( ! lowest || vp . compareTo ( lowest ) < 0 ) ) {
221223 lowest = vp
222224 }
0 commit comments