### Unit tests for functions in parseHLADataset.R file
library(HLAClustRView)
directory <- system.file("extdata", package = "HLAClustRView")
fileName <- paste0(directory, "/Samples_HLA_typing.txt")
### Tests readHLADataset() function
context("Test for readHLADataset() function")
test_that("readHLADataset() must return an error when hlaFilePath is a number", {
message <- "The hlaFilePath parameter must by a character string"
expect_error(readHLADataset(hlaFilePath = 33), message)
})
test_that("readHLADataset() must return an error when hlaFilePath is a number", {
message <- "The hlaFilePath parameter must by a character string"
expect_error(readHLADataset(hlaFilePath = TRUE), message)
})
test_that("parseHLADbAlignment() must return an error when hlaFilePath does not exist", {
path_to_test <- "./3_21_33eddger_39kdf_23sk2-2221fvd_qqqqqqqqqq_2.txt"
if (!dir.exists(path_to_test)) {
message <- paste0("The file '", path_to_test, "' must be a valid text file")
expect_error(readHLADataset(hlaFilePath = path_to_test), message)
}
})
test_that("parseHLADbAlignment() must return good result", {
result <- readHLADataset(hlaFilePath = fileName)
expected <- list()
SampleName <- c("ERR188053","ERR188053","ERR188053","ERR188053","ERR188053","ERR188053","ERR188053",
"ERR188053","ERR188053","ERR188053","ERR188053","ERR188053","ERR188053","ERR188053",
"ERR188053","ERR188053","ERR188053","ERR188053","ERR188053","ERR188053","ERR188053",
"ERR188053","ERR188053","ERR188053","ERR188053","ERR188053","ERR188053","ERR188053",
"ERR188053","ERR188053","ERR188053","ERR188053","ERR188053","ERR188053","ERR188053",
"ERR188053","ERR188053","ERR188053","ERR188465","ERR188465","ERR188465","ERR188465",
"ERR188465","ERR188465","ERR188465","ERR188465","ERR188465","ERR188465","ERR188465",
"ERR188465","ERR188465","ERR188465","ERR188465","ERR188465","ERR188465","ERR188465",
"ERR188465","ERR188465","ERR188465","ERR188465","ERR188465","ERR188465","ERR188465",
"ERR188465","ERR188465","ERR188465","ERR188465","ERR188465","ERR188465","ERR188465",
"ERR188465","ERR188465","ERR188465","ERR188465","ERR188465","ERR188465","ERR188040",
"ERR188040","ERR188040","ERR188040","ERR188040","ERR188040","ERR188040","ERR188040",
"ERR188040","ERR188040","ERR188040","ERR188040","ERR188040","ERR188040","ERR188040",
"ERR188040","ERR188040","ERR188040","ERR188040","ERR188040","ERR188040","ERR188040",
"ERR188040","ERR188040","ERR188040","ERR188040","ERR188040","ERR188040","ERR188040",
"ERR188040","ERR188040","ERR188040","ERR188040","ERR188040","ERR188040","ERR188040",
"ERR188040","ERR188040","ERR188189","ERR188189","ERR188189","ERR188189","ERR188189",
"ERR188189","ERR188189","ERR188189","ERR188189","ERR188189","ERR188189","ERR188189",
"ERR188189","ERR188189","ERR188189","ERR188189","ERR188189","ERR188189","ERR188189",
"ERR188189","ERR188189","ERR188189","ERR188189","ERR188189","ERR188189","ERR188189",
"ERR188189","ERR188189","ERR188189","ERR188189","ERR188189","ERR188189","ERR188189",
"ERR188189","ERR188189","ERR188189","ERR188189","ERR188189","ERR188117","ERR188117",
"ERR188117","ERR188117","ERR188117","ERR188117","ERR188117","ERR188117","ERR188117",
"ERR188117","ERR188117","ERR188117","ERR188117","ERR188117","ERR188117","ERR188117",
"ERR188117","ERR188117","ERR188117","ERR188117","ERR188117","ERR188117","ERR188117",
"ERR188117","ERR188117","ERR188117","ERR188117","ERR188117","ERR188117","ERR188117",
"ERR188117","ERR188117","ERR188117","ERR188117","ERR188117","ERR188117","ERR188117","ERR188117")
AlleleName <- c("1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1",
"2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2",
"1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1",
"2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2",
"1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1",
"2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2",
"1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1",
"2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2",
"1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2")
GeneName <- c("A","A","B","B","C","C","DMA","DMA","DMB","DMB","DOA","DOA","DOB","DOB","DPA1","DPA1","DPB1","DPB1",
"DQA1","DQA1","DQB1","DQB1","DRA","DRA","DRB1","DRB1","E","E","F","F","MICA","MICA","MICB","MICB","TAP1",
"TAP1","TAP2","TAP2","A","A","B","B","C","C","DMA","DMA","DMB","DMB","DOA","DOA","DOB","DOB","DPA1","DPA1",
"DPB1","DPB1","DQA1","DQA1","DQB1","DQB1","DRA","DRA","DRB1","DRB1","E","E","F","F","MICA","MICA","MICB",
"MICB","TAP1","TAP1","TAP2","TAP2","A","A","B","B","C","C","DMA","DMA","DMB","DMB","DOA","DOA","DOB","DOB",
"DPA1","DPA1","DPB1","DPB1","DQA1","DQA1","DQB1","DQB1","DRA","DRA","DRB1","DRB1","E","E","F","F","MICA",
"MICA","MICB","MICB","TAP1","TAP1","TAP2","TAP2","A","A","B","B","C","C","DMA","DMA","DMB","DMB","DOA",
"DOA","DOB","DOB","DPA1","DPA1","DPB1","DPB1","DQA1","DQA1","DQB1","DQB1","DRA","DRA","DRB1","DRB1","E",
"E","F","F","MICA","MICA","MICB","MICB","TAP1","TAP1","TAP2","TAP2","A","A","B","B","C","C","DMA","DMA",
"DMB","DMB","DOA","DOA","DOB","DOB","DPA1","DPA1","DPB1","DPB1","DQA1","DQA1","DQB1","DQB1","DRA","DRA",
"DRB1","DRB1","E","E","F","F","MICA","MICA","MICB","MICB","TAP1","TAP1","TAP2","TAP2")
AlleleGroup <- c("31","68","27","27","02","02","01","01","01","01","01","01","01","01","01","01","04","04","01","03","03",
"06","01","01","13","04","01","01","01","01","007","045","010","010","01","01","02","01","24","02","51",
"14","14","08","01","01","01","01","01","01","01","01","01","01","03","02","04","05","04","03","01","01",
"13","08","01","01","01","01","011","049","005","010","02","04","02","01","29","01","44","08","07","16",
"01","01","01","01","01","01","01","01","01","02","01","02","02","05","02","02","01","01","03","07","01",
"01","01","01","008","004","010","010","01","01","01","01","32","02","53","44","04","05","01","01","01",
"01","01","01","01","01","01","01","104","04","03","01","03","06","01","01","04","13","01","01","01","01",
"002","008","010","010","01","01","02","01","03","25","07","18","07","12","01","01","01","01","01","01",
"01","01","01","01","04","04","01","01","06","06","01","01","15","15","01","01","01","01","008","018","028","002","01","02","01","01")
Protein <- c("01","01","05","05","02","02","01","02","03","01","01","01","01","01","03","03","01","01","03","03","02","03",
"01","02","01","01","01","03","01","01","01",NA,NA,NA,"01","01","01","01","02","01","01","02","02","02",
"02","01","03","01","01","01","01","04","03","03","01","01","01","05","02","01","02","02","03","01","03","01",
"01","01",NA,NA,"03",NA,"01","01","01","02","02","01","03","01","01","01","01","01","03","01","01","01",
"01","01","03","01","01","01","01","01","01","02","01","02","01","01","01","03","01","01","01",NA,NA,NA,
"01","01","01","01","01","01","01","02","09","01","01","01","03","03","01","01","01","01","03","03","01","01",
"01","02","02","04","01","02","04","02","03","01","01","01","01","01",NA,NA,"01","01","01","02","01","01",
"02","01","02","03","01","01","01","01","01","01","01","01","03","03","01","01","02","02","02","02","02","02",
"01","01","01","03","03","01","04","01",NA,"01","01","01","01","02")
SynSubst <- c("02","01","02","02","02","02","01",NA,"01","01","04","02","03","01","01","01","01","01","01","01","01","01","01",
"02","01","01","01","02","01","01",NA,NA,NA,NA,"01","01","02","03","01","01","01","01","01","01",NA,"01",
"01","01","06","01","01","01","01","01","01","02","01","01","01","01","02","02","01","01","02","01","01","02",NA,
NA,NA,NA,"01",NA,"02",NA,"01","01","01","01","01","01","01","01","01","01","02","02","01","03","01","02",
"01","02","01","01","01","01","01","02","01","01","01","02","01","01","01",NA,NA,NA,"01","01","03","03","01",
"01","01","01",NA,"01","01","01","01","01","02","02","01","01","01","01",NA,"01","01","01","01","01","01","02",
"01","01","02","01","01","01",NA,"01",NA,NA,"01","01","02",NA,"01","01","01","01","01","01","01","01","01",
"01","02","01","01","03","01","01","01","01","01","01","01","01","03","03","01","01","01","02","01","01",NA,NA,NA,"01","01","01","03",NA)
NonCoding <- c("01","01",NA,NA,"01","01","01",NA,"01","01","02","01","01","01","01","01","01","01","01","01",NA,NA,"01",NA,
"01",NA,"01","01","01","01",NA,NA,NA,NA,"01","01","01","01","01","01","01","01","01","01",NA,"01","01","01",
NA,NA,"01","01","01","01",NA,NA,NA,"01",NA,"01",NA,NA,NA,NA,"01","01","01","01",NA,NA,NA,NA,
NA,NA,"01",NA,"01","01","01",NA,"01","01","01","01","01","01","01","01","01","01","01",NA,NA,NA,"01","01",
NA,"01","01",NA,"01","01","01","01","01","01",NA,NA,NA,NA,"01","01","01","01",NA,"01",NA,"01",NA,"01",
"01","01","01","01","01","01","01","01","01","01",NA,"01",NA,"01",NA,NA,"01",NA,NA,NA,"01","01","01","01",
NA,NA,NA,NA,"01","01","01",NA,"01",NA,NA,"01","01","01","01","01","01","01","01",NA,"01","01","01","01",
"01","01","01","01",NA,NA,NA,NA,"01","01","01","01","01","01",NA,NA,NA,NA,"01",NA,"01",NA)
Suffix <- c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
"novel",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,"N",NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,"updated",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,"novel",
"novel",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA)
expected[["data"]] <- tibble(SampleName=SampleName, AlleleName=AlleleName, GeneName=GeneName,
AlleleGroup=AlleleGroup, Protein=Protein,
SynSubst=SynSubst, NonCoding=NonCoding, Suffix=Suffix)
class(expected) <- "HLADataset"
expect_equal(result, expected)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.