From f6e87dffa862edf3f54f4b224e6972b6d83558f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciara=CC=81n=20O=E2=80=99Mara?= Date: Fri, 2 Apr 2021 01:00:24 +1100 Subject: [PATCH] Add `eof` check The addition of an eof check appears to cover a corner case detailed at https://github.com/BioJulia/XAM.jl/issues/31#issuecomment-787480072. # Conflicts: # src/bam/overlap.jl --- src/bam/overlap.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bam/overlap.jl b/src/bam/overlap.jl index 3f315b2..5e258de 100644 --- a/src/bam/overlap.jl +++ b/src/bam/overlap.jl @@ -63,7 +63,10 @@ function Base.iterate(iter::OverlapIterator, state) while state.chunkid ≤ lastindex(state.chunks) chunk = state.chunks[state.chunkid] while VirtualOffset(iter.reader.stream) < chunk.stop - read!(iter.reader, state.record) + if BioGenerics.IO.tryread!(iter.reader, state.record) === nothing + # no more overlapping records in this chunk since the end of the chunk was reached. + break + end c = compare_intervals(state.record, (state.refindex, iter.interval)) if c == 0 return copy(state.record), state