diff --git a/src/SequenceVariation.jl b/src/SequenceVariation.jl index 8b4ea6e..b8a630a 100644 --- a/src/SequenceVariation.jl +++ b/src/SequenceVariation.jl @@ -242,7 +242,8 @@ function Variant(aln::PairwiseAlignment{T, T}) where {T <: LongSequence{<:Union{ E = eltype(typeof(ref)) edits = Edit{T, E}[] result = Variant(ref, edits) - refpos = seqpos = 0 + refpos = first(aln.a.aln.anchors).refpos + seqpos = first(aln.a.aln.anchors).seqpos markpos = 0 n_gaps = n_ins = 0 insertion_buffer = E[] diff --git a/test/runtests.jl b/test/runtests.jl index 89947cd..78e4d0b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -32,4 +32,15 @@ const DNA_MODEL = BioAlignments.AffineGapScoreModel(EDNAFULL, gap_open=-25, gap_ align(a::BioSequence, b::BioSequence) = pairalign(GlobalAlignment(), a, b, DNA_MODEL).aln seq1 = ungap!(dna"--ATGCGTGTTAGCAAC--TTATCGCG") seq2 = ungap!(dna"TGATGCGTGT-AGCAACACTTATAGCG") -var = Variant(align(seq1, seq2)) \ No newline at end of file +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