mirror of
https://github.com/MillironX/XAM.jl.git
synced 2024-11-23 10:19:56 +00:00
Preallocate
This commit is contained in:
parent
789cccbaff
commit
b0069d6f27
1 changed files with 6 additions and 6 deletions
|
@ -87,7 +87,7 @@ function init_bam_reader(input::BGZFStreams.BGZFStream)
|
||||||
A = read(input, UInt8)
|
A = read(input, UInt8)
|
||||||
M = read(input, UInt8)
|
M = read(input, UInt8)
|
||||||
x = read(input, UInt8)
|
x = read(input, UInt8)
|
||||||
|
|
||||||
if B != UInt8('B') || A != UInt8('A') || M != UInt8('M') || x != 0x01
|
if B != UInt8('B') || A != UInt8('A') || M != UInt8('M') || x != 0x01
|
||||||
error("input was not a valid BAM file")
|
error("input was not a valid BAM file")
|
||||||
end
|
end
|
||||||
|
@ -97,16 +97,16 @@ function init_bam_reader(input::BGZFStreams.BGZFStream)
|
||||||
samreader = SAM.Reader(IOBuffer(read(input, textlen)))
|
samreader = SAM.Reader(IOBuffer(read(input, textlen)))
|
||||||
|
|
||||||
# reference sequences
|
# reference sequences
|
||||||
refseqnames = String[]
|
|
||||||
refseqlens = Int[]
|
|
||||||
n_refs = read(input, Int32)
|
n_refs = read(input, Int32)
|
||||||
for _ in 1:n_refs
|
refseqnames = Vector{String}(undef, n_refs)
|
||||||
|
refseqlens = Vector{Int}(undef, n_refs)
|
||||||
|
@inbounds for i in 1:n_refs
|
||||||
namelen = read(input, Int32)
|
namelen = read(input, Int32)
|
||||||
data = read(input, namelen)
|
data = read(input, namelen)
|
||||||
seqname = unsafe_string(pointer(data))
|
seqname = unsafe_string(pointer(data))
|
||||||
seqlen = read(input, Int32)
|
seqlen = read(input, Int32)
|
||||||
push!(refseqnames, seqname)
|
refseqnames[i] = seqname
|
||||||
push!(refseqlens, seqlen)
|
refseqlens[i] = seqlen
|
||||||
end
|
end
|
||||||
|
|
||||||
voffset = isa(input.io, Base.AbstractPipe) ?
|
voffset = isa(input.io, Base.AbstractPipe) ?
|
||||||
|
|
Loading…
Reference in a new issue