From d0f0f65d7f77d4103dffed0188202f8b458211d8 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Fri, 6 May 2022 05:25:07 -0500 Subject: [PATCH] Fix show function for Variations with Insertion edits (#3) Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- src/SequenceVariation.jl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/SequenceVariation.jl b/src/SequenceVariation.jl index bd3feef..8b4ea6e 100644 --- a/src/SequenceVariation.jl +++ b/src/SequenceVariation.jl @@ -66,7 +66,7 @@ outside this struct """ struct Deletion len::UInt - + function Deletion(len::UInt) iszero(len) && error("Deletion must be at least 1 symbol") new(len) @@ -156,7 +156,7 @@ let lastsymbol = symbol end end, - :digit => :(num = UInt(10)*num + (byte - 0x30) % UInt), + :digit => :(num = UInt(10)*num + (byte - 0x30) % UInt), ) @eval begin function Base.parse(::Type{Edit{S, T}}, data::BYTES) where {S, T} @@ -180,7 +180,7 @@ end struct Variant{S <: BioSequence, T <: BioSymbol} ref::S edits::Vector{Edit{S, T}} - + Variant{S, T}(ref::S, edits::Vector{Edit{S, T}}, ::Unsafe) where {S, T} = new(ref, edits) end @@ -360,6 +360,8 @@ function Base.show(io::IO, x::Variation) print(io, x.ref[pos], pos, content.x) elseif content isa Deletion print(io, 'Δ', pos, '-', pos + content.len - 1) + elseif content isa Insertion + print(io, pos, content.seq) else print(io, pos, content.x) end @@ -384,7 +386,7 @@ function translate(var::Variation{S, T}, aln::PairwiseAlignment{S, S}) where {S, (isgap(s) | isgap(r)) && return Inapplicable() return Variation{S, T}(seq, Edit{S, T}(Insertion(var.edit.x), 0)) end - + (seqpos, op) = BA.ref2seq(aln, pos) if kind isa Substitution # If it's a substitution, return nothing if it maps to a deleted @@ -416,7 +418,7 @@ function translate(var::Variation{S, T}, aln::PairwiseAlignment{S, S}) where {S, else return Inapplicable() end - end + end end export Insertion,