mirror of
https://github.com/MillironX/SequenceVariation.jl.git
synced 2024-11-25 22:59:56 +00:00
Fix show function for Variations with Insertion edits (#3)
Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com>
This commit is contained in:
parent
92a2d40553
commit
d0f0f65d7f
1 changed files with 7 additions and 5 deletions
|
@ -66,7 +66,7 @@ outside this struct
|
||||||
"""
|
"""
|
||||||
struct Deletion
|
struct Deletion
|
||||||
len::UInt
|
len::UInt
|
||||||
|
|
||||||
function Deletion(len::UInt)
|
function Deletion(len::UInt)
|
||||||
iszero(len) && error("Deletion must be at least 1 symbol")
|
iszero(len) && error("Deletion must be at least 1 symbol")
|
||||||
new(len)
|
new(len)
|
||||||
|
@ -156,7 +156,7 @@ let
|
||||||
lastsymbol = symbol
|
lastsymbol = symbol
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
:digit => :(num = UInt(10)*num + (byte - 0x30) % UInt),
|
:digit => :(num = UInt(10)*num + (byte - 0x30) % UInt),
|
||||||
)
|
)
|
||||||
@eval begin
|
@eval begin
|
||||||
function Base.parse(::Type{Edit{S, T}}, data::BYTES) where {S, T}
|
function Base.parse(::Type{Edit{S, T}}, data::BYTES) where {S, T}
|
||||||
|
@ -180,7 +180,7 @@ end
|
||||||
struct Variant{S <: BioSequence, T <: BioSymbol}
|
struct Variant{S <: BioSequence, T <: BioSymbol}
|
||||||
ref::S
|
ref::S
|
||||||
edits::Vector{Edit{S, T}}
|
edits::Vector{Edit{S, T}}
|
||||||
|
|
||||||
Variant{S, T}(ref::S, edits::Vector{Edit{S, T}}, ::Unsafe) where {S, T} = new(ref, edits)
|
Variant{S, T}(ref::S, edits::Vector{Edit{S, T}}, ::Unsafe) where {S, T} = new(ref, edits)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -360,6 +360,8 @@ function Base.show(io::IO, x::Variation)
|
||||||
print(io, x.ref[pos], pos, content.x)
|
print(io, x.ref[pos], pos, content.x)
|
||||||
elseif content isa Deletion
|
elseif content isa Deletion
|
||||||
print(io, 'Δ', pos, '-', pos + content.len - 1)
|
print(io, 'Δ', pos, '-', pos + content.len - 1)
|
||||||
|
elseif content isa Insertion
|
||||||
|
print(io, pos, content.seq)
|
||||||
else
|
else
|
||||||
print(io, pos, content.x)
|
print(io, pos, content.x)
|
||||||
end
|
end
|
||||||
|
@ -384,7 +386,7 @@ function translate(var::Variation{S, T}, aln::PairwiseAlignment{S, S}) where {S,
|
||||||
(isgap(s) | isgap(r)) && return Inapplicable()
|
(isgap(s) | isgap(r)) && return Inapplicable()
|
||||||
return Variation{S, T}(seq, Edit{S, T}(Insertion(var.edit.x), 0))
|
return Variation{S, T}(seq, Edit{S, T}(Insertion(var.edit.x), 0))
|
||||||
end
|
end
|
||||||
|
|
||||||
(seqpos, op) = BA.ref2seq(aln, pos)
|
(seqpos, op) = BA.ref2seq(aln, pos)
|
||||||
if kind isa Substitution
|
if kind isa Substitution
|
||||||
# If it's a substitution, return nothing if it maps to a deleted
|
# 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
|
else
|
||||||
return Inapplicable()
|
return Inapplicable()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
export Insertion,
|
export Insertion,
|
||||||
|
|
Loading…
Reference in a new issue