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

Minimal adjustements

This commit is contained in:
Ciarán O'Mara 2020-08-13 14:06:43 +10:00
parent 433b8d14e8
commit d38c2becf0
2 changed files with 18 additions and 13 deletions

View file

@ -511,9 +511,12 @@ end
Get the segment sequence of `record`. Get the segment sequence of `record`.
""" """
function sequence(record::Record)::BioSequences.LongDNASeq function sequence(record::Record)
checkfilled(record) checkfilled(record)
seqlen = seqlength(record) seqlen = seqlength(record)
if seqlen == 0
return nothing
end
data = Vector{UInt64}(undef, cld(seqlen, 16)) data = Vector{UInt64}(undef, cld(seqlen, 16))
src::Ptr{UInt64} = pointer(record.data, seqname_length(record) + n_cigar_op(record, false) * 4 + 1) src::Ptr{UInt64} = pointer(record.data, seqname_length(record) + n_cigar_op(record, false) * 4 + 1)
for i in 1:lastindex(data) for i in 1:lastindex(data)

View file

@ -206,9 +206,9 @@ Get the 1-based leftmost mapping position of `record`.
function position(record::Record)::Int function position(record::Record)::Int
checkfilled(record) checkfilled(record)
pos = unsafe_parse_decimal(Int, record.data, record.pos) pos = unsafe_parse_decimal(Int, record.data, record.pos)
if pos == 0 # if pos == 0
missingerror(:position) # missingerror(:position)
end # end
return pos return pos
end end
@ -263,9 +263,9 @@ Get the position of the mate/next read of `record`.
function nextposition(record::Record)::Int function nextposition(record::Record)::Int
checkfilled(record) checkfilled(record)
pos = unsafe_parse_decimal(Int, record.data, record.pnext) pos = unsafe_parse_decimal(Int, record.data, record.pnext)
if pos == 0 # if pos == 0
missingerror(:nextposition) # missingerror(:nextposition)
end # end
return pos return pos
end end
@ -299,7 +299,8 @@ Get the CIGAR string of `record`.
function cigar(record::Record)::String function cigar(record::Record)::String
checkfilled(record) checkfilled(record)
if ismissing(record, record.cigar) if ismissing(record, record.cigar)
missingerror(:cigar) # missingerror(:cigar)
return ""
end end
return String(record.data[record.cigar]) return String(record.data[record.cigar])
end end
@ -377,9 +378,9 @@ Get the template length of `record`.
function templength(record::Record)::Int function templength(record::Record)::Int
checkfilled(record) checkfilled(record)
len = unsafe_parse_decimal(Int, record.data, record.tlen) len = unsafe_parse_decimal(Int, record.data, record.tlen)
if len == 0 # if len == 0
missingerror(:tlen) # missingerror(:tlen)
end # end
return len return len
end end
@ -392,10 +393,11 @@ end
Get the segment sequence of `record`. Get the segment sequence of `record`.
""" """
function sequence(record::Record)::BioSequences.LongDNASeq function sequence(record::Record)
checkfilled(record) checkfilled(record)
if ismissing(record, record.seq) if ismissing(record, record.seq)
missingerror(:sequence) # missingerror(:sequence)
return nothing
end end
seqlen = length(record.seq) seqlen = length(record.seq)
ret = BioSequences.LongDNASeq(seqlen) ret = BioSequences.LongDNASeq(seqlen)