diff --git a/src/Variation.jl b/src/Variation.jl index af9f4df..851650a 100644 --- a/src/Variation.jl +++ b/src/Variation.jl @@ -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}