feat: Add _cigar_between(::Variation, ::Variation) function

Add a function that can calculate the matching bases between two
(non-matching) Variations and return a matching (M) CIGAR operation
This commit is contained in:
Thomas A. Christensen II 2023-04-04 11:32:21 -05:00
parent c3a7788dbd
commit e84f765357
Signed by: millironx
GPG key ID: 09335146883990B9

View file

@ -135,6 +135,26 @@ function _cigar(var::Variation{S,T}) where {S,T}
return string(length(mut), cigar_letter)
end
"""
_cigar_between(x::Variation{S,T}, y::Variation{S,T}) where {S,T}
Returns a CIGAR operation for the (assumed) matching bases between `x` and `y`.
See also [`_cigar`](@ref)
"""
function _cigar_between(x::Variation{S,T}, y::Variation{S,T}) where {S,T}
x == y && return ""
match_length = leftposition(y) - rightposition(x)
if mutation(y) isa Insertion
match_length -= 1
end
if mutation(y) isa Deletion
match_length += 1
end
match_length > 0 || return ""
return "$(match_length)M"
end
"""
translate(var::Variation{S,T}, aln::PairwiseAlignment{S,S}) where {S,T}