Skip to content

Commit cc8237c

Browse files
committed
count_aligned(): optimize with alnpos
1 parent 0156de4 commit cc8237c

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/pairwise/alignment.jl

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,7 @@ Count the number of aligned positions.
118118
"""
119119
function count_aligned(aln::PairwiseAlignment)
120120
anchors = aln.a.aln.anchors
121-
n = 0
122-
for i in 2:lastindex(anchors)
123-
op = anchors[i].op
124-
if ismatchop(op) || isinsertop(op)
125-
n += anchors[i].seqpos - anchors[i-1].seqpos
126-
elseif isdeleteop(op)
127-
n += anchors[i].refpos - anchors[i-1].refpos
128-
end
129-
end
130-
return n
121+
return isempty(anchors) ? 0 : last(anchors).alnpos
131122
end
132123

133124
seq2ref(aln::PairwiseAlignment, i::Integer) = seq2ref(aln.a, i)

0 commit comments

Comments
 (0)