From 8ce9f3af04cf6beae319663113c7d6724b5bb79a Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Mon, 23 Jan 2023 11:21:16 +0100 Subject: [PATCH] Translated testFastaData() (#3) --- R/testFastaData.R | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 R/testFastaData.R diff --git a/R/testFastaData.R b/R/testFastaData.R new file mode 100644 index 0000000..ad88256 --- /dev/null +++ b/R/testFastaData.R @@ -0,0 +1,19 @@ +testFastaData <- function(inFile) { + # added by Lu Cheng, 11.11.2012 + if (!exists(inFile, 'file')) { + stop('Fasta file ', inFile, ' does not exist!') + } + + seqs <- load_fasta(inFile) + heds <- colnames(seqs) + ninds <- length(seqs) + + data <- as.matrix(seqs) + newData <- ones(size(data)) * -9 + 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)) + return(list("ninds" = ninds, "data" = data, "heds" = heds)) +}