diff --git a/src/bam/bam.jl b/src/bam/bam.jl index 6fd1174..3a0064c 100644 --- a/src/bam/bam.jl +++ b/src/bam/bam.jl @@ -15,6 +15,20 @@ import BioGenerics: isfilled, header import GenomicFeatures: eachoverlap +# Overwrite virtualoffset method as per https://github.com/BioJulia/BGZFStreams.jl/issues/22#issuecomment-839746122. +function BGZFStreams.virtualoffset(stream::BGZFStreams.BGZFStream) + if stream.mode == BGZFStreams.READ_MODE + i = BGZFStreams.ensure_buffered_data(stream) + if i == 0 + block = stream.blocks[end] + else + block = stream.blocks[i] + end + else + block = stream.blocks[1] + end + return BGZFStreams.VirtualOffset(block.block_offset, block.position - 1) +end include("bai.jl") include("auxdata.jl")