mirror of
https://github.com/MillironX/XAM.jl.git
synced 2024-11-14 14:23:11 +00:00
Adjust BGZFStreams.ensure_buffered_data
https://github.com/BioJulia/BGZFStreams.jl/issues/22
This commit is contained in:
parent
6bc08e15b2
commit
b2bc94eb2b
1 changed files with 20 additions and 0 deletions
|
@ -15,6 +15,26 @@ import BioGenerics: isfilled, header
|
|||
|
||||
import GenomicFeatures: eachoverlap
|
||||
|
||||
# Overwrite `ensure_buffered_data` to address https://github.com/BioJulia/BGZFStreams.jl/issues/22.
|
||||
@inline function BGZFStreams.ensure_buffered_data(stream)
|
||||
#@assert stream.mode == READ_MODE
|
||||
@label doit
|
||||
while stream.block_index ≤ lastindex(stream.blocks)
|
||||
@inbounds block = stream.blocks[stream.block_index]
|
||||
if BGZFStreams.is_eof_block(block.compressed_block) # Note: `read_blocks!` does not necessarily fill/overwrite blocks till `lastindex(stream.blocks)`, we need to stop incrementing `stream.block_index` when an eof block is encountered.
|
||||
break
|
||||
end
|
||||
if block.position ≤ block.size
|
||||
return stream.block_index
|
||||
end
|
||||
stream.block_index += 1
|
||||
end
|
||||
if !BGZFStreams.eof(stream.io)
|
||||
BGZFStreams.read_blocks!(stream)
|
||||
@goto doit
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
include("bai.jl")
|
||||
include("auxdata.jl")
|
||||
|
|
Loading…
Reference in a new issue