Change alignment getter for BAM.Record to use existing cigar constructor

Rather than keep a copy of the BioAlignments cigar constructor embedded in
this function, have it call the existing constructor. There may be
performance implications for using `cigar` instead of `cigar_rle`, but
having a second copy of the constructor here is an antipattern if I've ever
seen one, so prioritise stable code over performant code.
develop
parent 946e77a734
commit e6f542a368
Signed by: millironx
GPG Key ID: 139C07724802BC5D

@ -430,27 +430,11 @@ end
Get the alignment of `record`.
"""
function alignment(record::Record)::BioAlignments.Alignment
checkfilled(record)
if !ismapped(record)
return BioAlignments.Alignment(BioAlignments.AlignmentAnchor[])
end
seqpos = 0
refpos = position(record) - 1
anchors = [BioAlignments.AlignmentAnchor(seqpos, refpos, BioAlignments.OP_START)]
for (op, len) in zip(cigar_rle(record)...)
if BioAlignments.ismatchop(op)
seqpos += len
refpos += len
elseif BioAlignments.isinsertop(op)
seqpos += len
elseif BioAlignments.isdeleteop(op)
refpos += len
else
error("operation $(op) is not supported")
end
push!(anchors, BioAlignments.AlignmentAnchor(seqpos, refpos, op))
if ismapped(record)
return BioAlignments.Alignment(cigar(record), 1, position(record))
end
return BioAlignments.Alignment(anchors)
return BioAlignments.Alignment(BioAlignments.AlignmentAnchor[])
end
function hasalignment(record::Record)

Loading…
Cancel
Save