private int countRecords(final SamReader reader) { int count = 0; try (final SAMRecordIterator iter = reader.iterator()) { while (iter.hasNext()) { iter.next(); count++; } } return count; }
private int countRecordsInQueryInterval(final SamReader reader, final QueryInterval query) { final SAMRecordIterator iter = reader.queryOverlapping(new QueryInterval[] {query}); int count = 0; while (iter.hasNext()) { iter.next(); count++; } iter.close(); return count; }