From 5ffb11439ea80d5e5bd180711bf91c0b7cf5e9b3 Mon Sep 17 00:00:00 2001 From: Alexey Stukalov Date: Tue, 22 Sep 2020 20:48:01 +0200 Subject: [PATCH] count_aligned(): optimize with agnpos --- src/pairwise/alignment.jl | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/pairwise/alignment.jl b/src/pairwise/alignment.jl index 4e7989c5..0ddf572b 100644 --- a/src/pairwise/alignment.jl +++ b/src/pairwise/alignment.jl @@ -118,16 +118,7 @@ Count the number of aligned positions. """ function count_aligned(aln::PairwiseAlignment) anchors = aln.a.aln.anchors - n = 0 - for i in 2:lastindex(anchors) - op = anchors[i].op - if ismatchop(op) || isinsertop(op) - n += anchors[i].seqpos - anchors[i-1].seqpos - elseif isdeleteop(op) - n += anchors[i].refpos - anchors[i-1].refpos - end - end - return n + return isempty(anchors) ? 0 : last(anchors).agnpos end seq2ref(aln::PairwiseAlignment, i::Integer) = seq2ref(aln.a, i)