Source:
protected BAMIndexContent query(final int referenceSequence, final int startPos, final int endPos) { if (metaDataPos > 0 && position() != metaDataPos) { seek(metaDataPos); } final List<Chunk> metaDataChunks = new ArrayList<Chunk>(); final int sequenceCount = getNumberOfReferences(); if (referenceSequence >= sequenceCount) { return null; } final BitSet regionBins = GenomicIndexUtil.regionToBins(startPos, endPos, getMinShift(), getBinDepth()); if (regionBins == null) { return null; } skipToSequence(referenceSequence); final int binCount = readInteger(); boolean metaDataSeen = false; final Bin[] bins = new BinWithOffset[getMaxBinNumberForReference(referenceSequence) +1]; for (int binNumber = 0; binNumber < binCount; binNumber++) { final int indexBin = readInteger(); final long lOffset = readLong(); final int nChunks = readInteger(); List<Chunk> chunks; Chunk lastChunk = null; if (regionBins.get(indexBin)) { chunks = new ArrayList<Chunk>(nChunks); for (int ci = 0; ci < nChunks; ci++) { final long chunkBegin = readLong(); final long chunkEnd = readLong(); lastChunk = new Chunk(chunkBegin, chunkEnd); chunks.add(lastChunk); } } else if (indexBin == getMaxBins() + 1) { for (int ci = 0; ci < nChunks; ci++) { final long chunkBegin = readLong(); final long chunkEnd = readLong(); lastChunk = new Chunk(chunkBegin, chunkEnd); metaDataChunks.add(lastChunk); } metaDataSeen = true; continue; } else { skipBytes(BAMFileConstants.CSI_CHUNK_SIZE * nChunks); chunks = Collections.emptyList(); } final BinWithOffset bin = new BinWithOffset(referenceSequence, indexBin, lOffset); bin.setChunkList(chunks); bin.setLastChunk(lastChunk); bins[indexBin] = bin; } return new BAMIndexContent(referenceSequence, bins, binCount - (metaDataSeen? 1 : 0), new BAMIndexMetaData(metaDataChunks), null); }

Target:
protected BAMIndexContent query(final int referenceSequence, final int startPos, final int endPos) { if (metaDataPos > 0 && position() != metaDataPos) { seek(metaDataPos); } final List<Chunk> metaDataChunks = new ArrayList<Chunk>(); final int sequenceCount = getNumberOfReferences(); if (referenceSequence >= sequenceCount) { return null; } final BitSet regionBins = GenomicIndexUtil.regionToBins(startPos, endPos, getMinShift(), getBinDepth()); if (regionBins == null) { return null; } skipToSequence(referenceSequence); final int binCount = readInteger(); boolean metaDataSeen = false; final Bin[] bins = new BinWithOffset[getMaxBinNumberForReference(referenceSequence) +1]; for (int binNumber = 0; binNumber < binCount; binNumber++) { final int indexBin = readInteger(); final long lOffset = readLong(); final int nChunks = readInteger(); List<Chunk> chunks; Chunk lastChunk = null; if (regionBins.get(indexBin)) { chunks = new ArrayList<Chunk>(nChunks); readChunks(nChunks, chunks); } else if (indexBin == getMaxBins() + 1) { readChunks(nChunks, metaDataChunks); metaDataSeen = true; continue; } else { skipBytes(BAMFileConstants.CSI_CHUNK_SIZE * nChunks); chunks = Collections.emptyList(); } final BinWithOffset bin = new BinWithOffset(referenceSequence, indexBin, lOffset); bin.setChunkList(chunks); bin.setLastChunk(lastChunk); bins[indexBin] = bin; } return new BAMIndexContent(referenceSequence, bins, binCount - (metaDataSeen? 1 : 0), new BAMIndexMetaData(metaDataChunks), null); }