feat: Add _cigar(::Variation) function

Add a function that can convert the information contained in an
Insertion or a Deletion into a CIGAR operator.
This commit is contained in:
Thomas A. Christensen II 2023-04-04 11:30:59 -05:00
parent 011651857f
commit c3a7788dbd
Signed by: millironx
GPG key ID: 09335146883990B9

View file

@ -120,6 +120,21 @@ function Base.in(v::Variation, var::Haplotype)
return any(v.edit == edit for edit in var.edits) return any(v.edit == edit for edit in var.edits)
end end
"""
_cigar(var::Variation{S,T}) where {S,T}
Returns a CIGAR operation for `var`. Only supports insertions and deletions.
See also [`_cigar_between`](@ref)
"""
function _cigar(var::Variation{S,T}) where {S,T}
mut = mutation(var)
mut isa Union{Deletion,Insertion} ||
throw(ArgumentError("var must be an Insertion or Deletion"))
cigar_letter = mut isa Deletion ? 'D' : 'I'
return string(length(mut), cigar_letter)
end
""" """
translate(var::Variation{S,T}, aln::PairwiseAlignment{S,S}) where {S,T} translate(var::Variation{S,T}, aln::PairwiseAlignment{S,S}) where {S,T}