Skip to content

Commit

Permalink
make pairwise_hamming of single alignment faster
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBarrat committed Oct 23, 2024
1 parent 3f818d1 commit 3937097
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,19 @@ function pairwise_hamming(
D
end
end
pairwise_hamming(X::AbstractAlignment; kwargs...) = pairwise_hamming(X, X; kwargs...)
function pairwise_hamming(X::AbstractAlignment; step=1, kwargs...)
n = 0
M = size(X, 2)
for i in 1:step:M, j in (i+1):step:M
n += 1
end

H = zeros(Float64, n)
n = 1
for i in 1:step:M, j in (i+1):step:M
H[n] = hamming(X[i], X[j]; kwargs...)
n += 1
end

return H
end

0 comments on commit 3937097

Please sign in to comment.