From f2b03a05a82527341e9512a1b16ffb7df9dc7407 Mon Sep 17 00:00:00 2001 From: Stevie Ped Date: Fri, 5 Apr 2024 00:56:34 +1030 Subject: [PATCH] Ran github actions --- DESCRIPTION | 2 +- R/helpers.R | 5 +++++ tests/testthat/test_helpers.R | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e2ebfd3..7e6043b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: transmogR Type: Package Title: Modify a set of reference sequences using a set of variants -Version: 0.99.3 +Version: 0.99.5 Authors@R: person("Stevie", "Pederson", email = "stephen.pederson.au@gmail.com", role = c("aut", "cre"), diff --git a/R/helpers.R b/R/helpers.R index d1aefa7..1db1e14 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -8,11 +8,16 @@ ## Deal with NAs alts <- mcols(var)[[alt_col]] if (is(alts, "XStringSetList")) alts <- as.character(unlist(alts)) + if (length(alts) != length(var)) + stop("Some alternate alleles have been specified with multiple values") is_na <- is.na(alts) if (any(is_na)) message("NA values found in ", alt_col, ". Removing...") var <- var[!is_na] if (all(is_na) & length(is_na) > 0) stop("All NA values in ", alt_col) + if (any(nchar(alts) == 0)) + stop("Please set Deletions so that width(REF) > 1 and width(ALT) > 0") + ## Check Non-IUPAC alt alleles iupac <- paste(names(IUPAC_CODE_MAP), collapse = "") pat <- paste0("^[", iupac, "]+$") diff --git a/tests/testthat/test_helpers.R b/tests/testthat/test_helpers.R index 6666001..7bff1af 100644 --- a/tests/testthat/test_helpers.R +++ b/tests/testthat/test_helpers.R @@ -1,6 +1,8 @@ test_that(".checkAlts behaves correctly", { gr <- GenomicRanges::GRanges("chr1:1") gr$ALT <- "" + expect_error(.checkAlts(gr, "ALT"), "Please set Deletions.+") + gr$ALT <- "x" expect_error(.checkAlts(gr, "ALT"), "Non-IUPAC.+") gr$ALT <- NA @@ -31,7 +33,7 @@ test_that(".makeIntersectionArgs behaves correctly",{ types <- c( mapping = "call", counts = "logical", bar_number_threshold = "numeric", text_colors = "call", text = "call", text_mapping = "call", mode = "character", - position = "call", fill = "character" + position = "call", width = "numeric", fill = "character" ) expect_equal(vapply(new, \(x) is(x)[[1]], character(1)), types) expect_true(new$bar_number_threshold == 1)