From 4817c8016add1e47e88f8eff9782407488d38a90 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 4 Apr 2023 11:50:24 -0500 Subject: [PATCH] feat: Add alignment(::Haplotype) function --- src/Haplotype.jl | 11 +++++++++++ src/SequenceVariation.jl | 10 +++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Haplotype.jl b/src/Haplotype.jl index f5cf985..9164455 100644 --- a/src/Haplotype.jl +++ b/src/Haplotype.jl @@ -250,6 +250,17 @@ function BioAlignments.cigar(hap::Haplotype{S,T}) where {S,T} return join(cigar_string, "") end +""" + alignment(hap::Haplotype) + +Gets a `PairwiseAlignment` of the mutated sequence of `hap` mapped to its refernce sequence +""" +function BioAlignments.alignment(hap::Haplotype) + return PairwiseAlignment( + AlignedSequence(reconstruct(hap), Alignment(cigar(hap))), reference(hap) + ) +end + """ translate(hap::Haplotype{S,T}, aln::PairwiseAlignment{S,S}) where {S,T} diff --git a/src/SequenceVariation.jl b/src/SequenceVariation.jl index 37b0a42..e8e7210 100644 --- a/src/SequenceVariation.jl +++ b/src/SequenceVariation.jl @@ -20,7 +20,15 @@ TODO now: * Add tests """ -using BioAlignments: BioAlignments, PairwiseAlignment, OP_SOFT_CLIP, cigar, sequence +using BioAlignments: + BioAlignments, + Alignment, + AlignedSequence, + PairwiseAlignment, + OP_SOFT_CLIP, + alignment, + cigar, + sequence using BioGenerics: BioGenerics, leftposition, rightposition using BioSequences: BioSequences, BioSequence, NucleotideSeq, LongSequence, isgap using BioSymbols: BioSymbol