1
0
Fork 0
mirror of https://github.com/MillironX/XAM.jl.git synced 2024-11-14 14:23:11 +00:00

Cater for blank sam files

This commit is contained in:
Ciarán O’Mara 2021-04-01 11:48:02 +11:00
parent 64f371e1e4
commit c423694f29
2 changed files with 17 additions and 7 deletions

View file

@ -94,17 +94,21 @@ end
Read a `Record` into `rec`; overwriting or adding to existing field values.
It is assumed that `rec` is already initialized or empty.
"""
function Base.read!(rdr::Reader, rec::Record)
function Base.read!(rdr::Reader, record::Record)
cs, ln, f = readrecord!(rdr.state.stream, rec, (rdr.state.state, rdr.state.linenum))
cs, ln, found = readrecord!(rdr.state.stream, record, (rdr.state.state, rdr.state.linenum))
rdr.state.state = cs
rdr.state.linenum = ln
rdr.state.filled = f
rdr.state.filled = found
if !f
cs == 0 && throw(EOFError())
throw(ArgumentError("malformed SAM file"))
if found
return record
end
return rec
if cs == 0 || eof(rdr.state.stream)
throw(EOFError())
end
throw(ArgumentError("malformed SAM file"))
end

View file

@ -194,5 +194,11 @@
close(reader)
# Test blank file.
file_sam = joinpath(samdir, "xx#blank.sam")
records = open(collect, SAM.Reader, file_sam)
@test records == []
end
end