Source:
<code>public static int lessExhaustivelyTestIndex(final SamReader reader) { if (reader.indexing().hasBrowseableIndex()) { final CachingBAMFileIndex existingIndex = (CachingBAMFileIndex) reader.indexing().getBrowseableIndex(); final int n_ref = existingIndex.getNumberOfReferences(); int chunkCount = 0; int indexCount = 0; for (int i = 0; i < n_ref; i++) { final boolean validateThisReference = (i == 0 || i == (n_ref-1)); <START> final BAMIndexContent content = existingIndex.getQueryResults(i); <END> if (validateThisReference) { for (final Chunk c : content.getAllChunks()) { final CloseableIterator<SAMRecord> iter = ((SamReader.PrimitiveSamReaderToSamReaderAdapter) reader).iterator(new BAMFileSpan(c)); chunkCount++; BAMRecord b = null; try { b = (BAMRecord) iter.next(); iter.close(); } catch (final Exception e) { throw new SAMException("Exception in BamIndexValidator. Last good record " + b + " in chunk " + c + " chunkCount=" + chunkCount, e); } } } else { chunkCount += content.getAllChunks().size(); } final LinearIndex linearIndex = content.getLinearIndex(); if (validateThisReference) { for (final long l : linearIndex.getIndexEntries()) { try { if (l != 0) { final CloseableIterator<SAMRecord> iter = ((SamReader.PrimitiveSamReaderToSamReaderAdapter) reader).iterator(new BAMFileSpan(new Chunk(l, l + 1))); final BAMRecord b = (BAMRecord) iter.next(); indexCount++; iter.close(); } } catch (final Exception e) { throw new SAMException("Exception in BamIndexValidator. Linear index access failure " + l + " indexCount=" + indexCount, e); } } } else { indexCount += linearIndex.getIndexEntries().length; } } return chunkCount; } return 0; }</code><technical_language>do need this call if reference contig</technical_language>

Target:
public static int lessExhaustivelyTestIndex(final SamReader reader) { if (reader.indexing().hasBrowseableIndex()) { final CachingBAMFileIndex existingIndex = (CachingBAMFileIndex) reader.indexing().getBrowseableIndex(); final int numRefs = existingIndex.getNumberOfReferences(); int chunkCount = 0; int indexCount = 0; for (int i = 0; i < numRefs; i++) { final BAMIndexContent content = existingIndex.getQueryResults(i); final List<Chunk> chunks = content.getAllChunks(); final int numChunks = chunks.size(); for (final int chunkNo : Arrays.asList(0, numChunks - 1)) { chunkCount++; final Chunk c = chunks.get(chunkNo); final CloseableIterator<SAMRecord> iter = ((SamReader.PrimitiveSamReaderToSamReaderAdapter) reader).iterator(new BAMFileSpan(c)); try { final SAMRecord sam = iter.next(); iter.close(); } catch (final Exception e) { throw new SAMException("Exception querying chunk " + chunkNo + " from reference index " + i, e); } } final long linearIndexEntries[] = content.getLinearIndex().getIndexEntries(); for (final int binNo : Arrays.asList(0, linearIndexEntries.length - 1)) { indexCount++; final long l = linearIndexEntries[binNo]; try { if (l != 0) { final CloseableIterator<SAMRecord> iter = ((SamReader.PrimitiveSamReaderToSamReaderAdapter) reader).iterator(new BAMFileSpan(new Chunk(l, l + 1))); final SAMRecord sam = iter.next(); iter.close(); } } catch (final Exception e) { throw new SAMException("Exception in BamIndexValidator. Linear index access failure " + l + " indexCount=" + indexCount, e); } } } return chunkCount; } return 0; }