mirror of
https://github.com/MillironX/SequenceVariation.jl.git
synced 2024-11-22 13:29:56 +00:00
Fix tests for translate(::Variation)
This commit is contained in:
parent
239b366a1c
commit
e251b292a7
1 changed files with 7 additions and 6 deletions
|
@ -138,7 +138,7 @@ function translate(var::Variation{S,T}, aln::PairwiseAlignment{S,S}) where {S,T}
|
||||||
if iszero(pos)
|
if iszero(pos)
|
||||||
(s, r), _ = iterate(aln)
|
(s, r), _ = iterate(aln)
|
||||||
(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(kind.seq), 0))
|
||||||
end
|
end
|
||||||
|
|
||||||
(seqpos, op) = BA.ref2seq(aln, pos)
|
(seqpos, op) = BA.ref2seq(aln, pos)
|
||||||
|
@ -153,18 +153,19 @@ function translate(var::Variation{S,T}, aln::PairwiseAlignment{S,S}) where {S,T}
|
||||||
# If it's a deletion, return nothing if the deleted part is already missing
|
# If it's a deletion, return nothing if the deleted part is already missing
|
||||||
# from the new reference.
|
# from the new reference.
|
||||||
(stop, op2) = BA.ref2seq(aln, pos + length(kind) - 1)
|
(stop, op2) = BA.ref2seq(aln, pos + length(kind) - 1)
|
||||||
start = seqpos + op == BA.OP_DELETE
|
start = seqpos + (op == BA.OP_DELETE)
|
||||||
start < stop && return nothing
|
del_len = stop - start + 1
|
||||||
edit = Edit{S,T}(Deletion(stop - start + 1), start)
|
del_len > 0 || return nothing
|
||||||
|
edit = Edit{S,T}(Deletion(del_len), start)
|
||||||
return Variation{S,T}(seq, edit, Unsafe())
|
return Variation{S,T}(seq, edit, Unsafe())
|
||||||
else
|
else
|
||||||
# If it maps directly to a symbol, just insert
|
# If it maps directly to a symbol, just insert
|
||||||
if op in (BA.OP_MATCH, BA.OP_SEQ_MATCH, BA.OP_SEQ_MISMATCH)
|
if op in (BA.OP_MATCH, BA.OP_SEQ_MATCH, BA.OP_SEQ_MISMATCH)
|
||||||
# This happens if there is already an insertion at the position
|
# This happens if there is already an insertion at the position
|
||||||
if pos != lastindex(ref) && first(ref2seq(aln, pos + 1)) != seqpos + 1
|
if pos != lastindex(ref) && first(BA.ref2seq(aln, pos + 1)) != seqpos + 1
|
||||||
return Inapplicable()
|
return Inapplicable()
|
||||||
else
|
else
|
||||||
edit = Edit{S,T}(Insertion(var.edit.x), seqpos)
|
edit = Edit{S,T}(Insertion(mutation(var).seq), seqpos)
|
||||||
return Variation{S,T}(seq, edit, Unsafe())
|
return Variation{S,T}(seq, edit, Unsafe())
|
||||||
end
|
end
|
||||||
# Alternatively, it can map to a deletion. In that case, it become really
|
# Alternatively, it can map to a deletion. In that case, it become really
|
||||||
|
|
Loading…
Reference in a new issue