Merge branch 'issue-3' into develop
This commit is contained in:
commit
606078c355
3 changed files with 14 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
|||
Package: rBAPS
|
||||
Title: Bayesian Analysis of Population Structure
|
||||
Version: 0.0.0.9017
|
||||
Version: 0.0.0.9018
|
||||
Date: 2020-11-09
|
||||
Authors@R:
|
||||
c(
|
||||
|
|
|
|||
|
|
@ -1,19 +1,20 @@
|
|||
testFastaData <- function(inFile) {
|
||||
# added by Lu Cheng, 11.11.2012
|
||||
if (!exists(inFile, 'file')) {
|
||||
if (!file.exists(inFile)) {
|
||||
stop('Fasta file ', inFile, ' does not exist!')
|
||||
}
|
||||
|
||||
seqs <- load_fasta(inFile)
|
||||
heds <- colnames(seqs)
|
||||
ninds <- length(seqs)
|
||||
ninds <- nrow(seqs) # not sure if this should be nrow, ncols or length
|
||||
|
||||
data <- as.matrix(seqs)
|
||||
newData <- ones(size(data)) * -9
|
||||
newData <- matrix(-9, nrow = nrow(data), ncol = ncol(data))
|
||||
newData[toupper(data) == 'A'] <- 1
|
||||
newData[toupper(data) == 'C'] <- 2
|
||||
newData[toupper(data) == 'G'] <- 3
|
||||
newData[toupper(data) == 'T'] <- 4
|
||||
data <- c(newData, t(1:ninds))
|
||||
|
||||
data <- cbind(newData, seq(1, ninds))
|
||||
return(list("ninds" = ninds, "data" = data, "heds" = heds))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,3 +51,11 @@ test_that("lakseKlitik() and subfunctions produce expected output", {
|
|||
# TODO: ... and anythin left from findCliques.m
|
||||
# TODO: test lakseKlitik()
|
||||
})
|
||||
|
||||
test_that("testFastaData() produces same output as on MATLAB", {
|
||||
msa <- system.file("ext", "seqs.fa", package = "rBAPS")
|
||||
test_msa <- testFastaData(msa)
|
||||
expect_equal(test_msa$ninds, 515)
|
||||
expect_equal(dim(test_msa$data), c(515, 745))
|
||||
expect_named(table(test_msa$data), c("-9", as.character(1:515)))
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue