Fix inconsistent Variation positions (#4)

* Change Variant constructor to use alignment positions

Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com>

* Add test for positions of Variations

Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com>
This commit is contained in:
Thomas A. Christensen II 2022-05-06 05:26:49 -05:00 committed by GitHub
parent d0f0f65d7f
commit ade9b7e41d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -242,7 +242,8 @@ function Variant(aln::PairwiseAlignment{T, T}) where {T <: LongSequence{<:Union{
E = eltype(typeof(ref)) E = eltype(typeof(ref))
edits = Edit{T, E}[] edits = Edit{T, E}[]
result = Variant(ref, edits) result = Variant(ref, edits)
refpos = seqpos = 0 refpos = first(aln.a.aln.anchors).refpos
seqpos = first(aln.a.aln.anchors).seqpos
markpos = 0 markpos = 0
n_gaps = n_ins = 0 n_gaps = n_ins = 0
insertion_buffer = E[] insertion_buffer = E[]

View file

@ -33,3 +33,14 @@ align(a::BioSequence, b::BioSequence) = pairalign(GlobalAlignment(), a, b, DNA_M
seq1 = ungap!(dna"--ATGCGTGTTAGCAAC--TTATCGCG") seq1 = ungap!(dna"--ATGCGTGTTAGCAAC--TTATCGCG")
seq2 = ungap!(dna"TGATGCGTGT-AGCAACACTTATAGCG") seq2 = ungap!(dna"TGATGCGTGT-AGCAACACTTATAGCG")
var = Variant(align(seq1, seq2)) var = Variant(align(seq1, seq2))
@testset "VariationPosition" begin
refseq = dna"ACAACTTTATCT"
mutseq = dna"ACATCTTTATCT"
read01 = AlignedSequence(mutseq[1:10], Alignment("10M", 1, 1))
read02 = AlignedSequence(mutseq[3:12], Alignment("10M", 1, 3))
aln01 = PairwiseAlignment(read01, refseq)
aln02 = PairwiseAlignment(read02, refseq)
@test Variant(aln01).edits == Variant(aln02).edits
end