final SBIIndexWriter indexWriter = new SBIIndexWriter(out, granularity); while (true) { try {
final SBIIndexWriter indexWriter = new SBIIndexWriter(out, granularity); while (true) { try {
private SBIIndex fromSAMRecords(final File bamFile, final long granularity) throws IOException { final BAMFileReader bamFileReader = bamFileReader(bamFile); try (CloseableIterator<SAMRecord> iterator = bamFileReader.getIterator(); ByteArrayOutputStream out = new ByteArrayOutputStream()) { final SBIIndexWriter indexWriter = new SBIIndexWriter(out, granularity); while (iterator.hasNext()) { processAlignment(indexWriter, iterator.next()); } indexWriter.finish(bamFileReader.getVirtualFilePointer(), bamFile.length()); return SBIIndex.load(new ByteArrayInputStream(out.toByteArray())); } }