Skip to content
Snippets Groups Projects
Commit 42d6ff2d authored by dj44vuri's avatar dj44vuri
Browse files

autodetect in readdesign

parent fc6b1247
No related branches found
No related tags found
No related merge requests found
......@@ -22,22 +22,22 @@
readdesign <- function(design = designfile, designtype = NULL) {
# if (is.null(designtype)) {
#
#
#
# # Check if the string ends with ".ngd"
# if (grepl("\\.ngd$", designfile)) {
# # Code to execute if condition is true
# designtype = "ngene"
# print("I guessed it is an ngene file")
# } else {
# # Code to execute if condition is false
# designtype = "spdesign"
# print("I assume it is a spdesign")
# }
#
# }
if (is.null(designtype)) {
# Check if the string ends with ".ngd"
if (grepl("\\.ngd$", designfile)) {
# Code to execute if condition is true
designtype = "ngene"
print("I guessed it is an ngene file")
} else {
# Code to execute if condition is false
designtype = "spdesign"
print("I assume it is a spdesign")
}
}
design <- switch(designtype,
"ngene" = suppressWarnings(readr::read_delim(design,
......
No preview for this file type
......@@ -15,14 +15,27 @@ test_that("all is correct", {
expect_no_error(readdesign(design = design_path, designtype = "ngene"))
})
# test if autodetect ngd design
test_that("all is correct", {
expect_no_error(readdesign(design = design_path))
})
### Tests for spdesign
design_path <- system.file("extdata","CSA", "design2.RDS" ,package = "simulateDCE")
design_path <- system.file("extdata","CSA", "linear", "BLIbay.RDS" ,package = "simulateDCE")
test_that("all is correct", {
expect_no_error(readdesign(design = design_path, designtype = "spdesign"))
})
# Same Tests for spdesign, but detect automatically if it is spdesign
test_that("all is correct", {
expect_no_error(readdesign(design = design_path))
})
## trying objects that do not work
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment