Skip to content

Commit 22fd02f

Browse files
committed
add unit test coverage for makeBaseHGVS, makeAAHGVS and groupSimilarSequences
1 parent a1525ce commit 22fd02f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/testthat/test_digestFastqs_helpers.R

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,10 @@ test_that("makeBaseHGVS works", {
513513
expect_equal(makeBaseHGVS(c("f.1.A", "r.4.A", "f.6.C"), ".", "TAGTGTAGTCCGT", "AAGAGCAGTCCGT"),
514514
"[1T>A;4_6delinsAGC]_")
515515
expect_equal(makeBaseHGVS(c("r.4.A"), ".", "TAGTGTAGTCCGT", "TAGAGTAGTCCGT"), "4T>A_")
516+
expect_equal(makeBaseHGVS(character(0), ".", "AAA", "AAA"), "_")
517+
expect_equal(makeBaseHGVS(c("f.1.A", "r.4.A", "r.8.A"), ".",
518+
"TACTTTAT", "AAGAAAAA"),
519+
"[1T>A;4T>A;8T>A]_")
516520
})
517521

518522
test_that("makeAAHGVS works", {
@@ -524,6 +528,8 @@ test_that("makeAAHGVS works", {
524528
"[(Thr1Leu);(Asp2Met)]_")
525529
expect_equal(test_makeAAHGVS(c("f.1.L", "f.2.M", "f.7.M"), ".", "TDTLQAETDQLEDEKSALQTEIANLLKEKEKL"),
526530
"[(Thr1Leu);(Asp2Met);(Glu7Met)]_")
531+
expect_equal(test_makeAAHGVS(character(0), ".", "TDTL"), "_")
532+
})
527533

528534
## ----------------------------------------------------------------------------
529535
## compareToWildtype
@@ -586,4 +592,22 @@ test_that("compareToWildtype works", {
586592
collapseToWT = TRUE),
587593
list())
588594
})
595+
596+
## ----------------------------------------------------------------------------
597+
## groupSimilarSequences
598+
## ----------------------------------------------------------------------------
599+
test_that("groupSimilarSequences works", {
600+
expect_identical(
601+
groupSimilarSequences(c("AA", "AT", "AC", "TT"), 1:4, collapseMaxDist = 0),
602+
data.frame(sequence = c("AA", "AT", "AC", "TT"),
603+
representative = c("AA", "AT", "AC", "TT"))
604+
)
605+
expect_identical(
606+
groupSimilarSequences(c("AA", "AT", "AC", "TT"), 1:4, collapseMaxDist = 1),
607+
data.frame(sequence = c("AA", "AT", "AC", "TT"),
608+
representative = c("AC", "TT", "AC", "TT"))
609+
)
610+
expect_warning(groupSimilarSequences(c("AA", "AT", "AC", "TTT"), 1:4,
611+
collapseMaxDist = 1),
612+
"not all of the same length")
589613
})

0 commit comments

Comments
 (0)