mirror of
https://github.com/MillironX/XAM.jl.git
synced 2024-12-23 13:28:16 +00:00
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.
This commit is contained in:
parent
946e77a734
commit
e6f542a368
1 changed files with 4 additions and 20 deletions
|
@ -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[])
|
||||
if ismapped(record)
|
||||
return BioAlignments.Alignment(cigar(record), 1, position(record))
|
||||
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))
|
||||
end
|
||||
return BioAlignments.Alignment(anchors)
|
||||
|
||||
return BioAlignments.Alignment(BioAlignments.AlignmentAnchor[])
|
||||
end
|
||||
|
||||
function hasalignment(record::Record)
|
||||
|
|
Loading…
Reference in a new issue