From c3a7788dbd3e5881877c3e5bba5ce19eb0b8959c Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 4 Apr 2023 11:30:59 -0500 Subject: [PATCH] feat: Add _cigar(::Variation) function Add a function that can convert the information contained in an Insertion or a Deletion into a CIGAR operator. --- src/Variation.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Variation.jl b/src/Variation.jl index 8af22bd..af9f4df 100644 --- a/src/Variation.jl +++ b/src/Variation.jl @@ -120,6 +120,21 @@ function Base.in(v::Variation, var::Haplotype) return any(v.edit == edit for edit in var.edits) 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}