From 7bd39b1d54418040d69a420cc0e06ec573f52a11 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Sat, 21 Jan 2023 18:10:04 -0600 Subject: [PATCH] Add tests for _is_valid(::Haplotype) --- test/runtests.jl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index fdaa9dc..18ba9f1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -45,6 +45,9 @@ seq2 = ungap!(dna"TGATGCGTGT-AGCAACACTTATAGCG") seq3 = ungap!(dna"-GATGCGTGT-AGCAACACTTATCGC-") var = Haplotype(align(seq1, seq2)) +const SEQ = typeof(seq1) +const BSE = eltype(seq1) + @testset "EditSorting" begin S = typeof(seq1) T = eltype(seq1) @@ -55,6 +58,11 @@ var = Haplotype(align(seq1, seq2)) end @testset "HaplotypeValidation" begin + # Test that we can't use an empty reference + @test_throws ErrorException Haplotype( + dna"", [SequenceVariation.Edit{SEQ,BSE}(Insertion{SEQ}(dna"A"), 0)] + ) + # Test that substitutions cannot share the same position @test_throws ErrorException Haplotype( seq2, [Variation(seq2, "T2A"), Variation(seq2, "T2C")] @@ -87,6 +95,21 @@ end @test_throws ErrorException Haplotype( seq2, [Variation(seq2, "Δ2-6"), Variation(seq2, "Δ3-5")] ) + + # Test that a complicated (but valid) Haplotype still checks out + @test first( + SequenceVariation._is_valid( + Haplotype( + seq2, + [ + Variation(seq2, "0AAA"), + Variation(seq2, "T2A"), + Variation(seq2, "Δ5-8"), + Variation(seq2, "G26A"), + ], + ), + ), + ) end @testset "HaplotypeRoundtrip" begin