From 5be4dce200ad3e4f9ea121c9159e5ec30d7c6eb1 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 6 Dec 2022 11:05:18 -0600 Subject: [PATCH] Add check for soft clips when construction Variants from alignment --- src/SequenceVariation.jl | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/SequenceVariation.jl b/src/SequenceVariation.jl index de19df1..a5ea12c 100644 --- a/src/SequenceVariation.jl +++ b/src/SequenceVariation.jl @@ -20,7 +20,7 @@ TODO now: * Add tests """ -using BioAlignments: BioAlignments, PairwiseAlignment +using BioAlignments: BioAlignments, PairwiseAlignment, OP_SOFT_CLIP using BioGenerics: BioGenerics, leftposition, rightposition using BioSequences: BioSequences, BioSequence, NucleotideSeq, LongSequence, isgap using BioSymbols: BioSymbol @@ -300,11 +300,16 @@ function Variant(aln::PairwiseAlignment{T, T}) where {T <: LongSequence{<:Union{ end end + # Check for clips at the end of the alignment + last_anchors = aln.a.aln.anchors[end-1:end] + # Final indel, if applicable - if !iszero(n_gaps) - push!(edits, Edit{T, E}(Deletion(UInt(n_gaps)), UInt(markpos))) - elseif !iszero(n_ins) - push!(edits, Edit{T, E}(Insertion(T(insertion_buffer)), UInt(markpos))) + if !any(anchor -> anchor.op == OP_SOFT_CLIP, last_anchors) + if !iszero(n_gaps) + push!(edits, Edit{T, E}(Deletion(UInt(n_gaps)), UInt(markpos))) + elseif !iszero(n_ins) + push!(edits, Edit{T, E}(Insertion(T(insertion_buffer)), UInt(markpos))) + end end return result