ourMELONS/R/testFastaData.R

21 lines
627 B
R
Raw Normal View History

2023-01-23 11:21:16 +01:00
testFastaData <- function(inFile) {
# added by Lu Cheng, 11.11.2012
2023-02-07 10:37:00 +01:00
if (!file.exists(inFile)) {
2023-01-23 11:21:16 +01:00
stop('Fasta file ', inFile, ' does not exist!')
}
seqs <- load_fasta(inFile)
heds <- colnames(seqs)
2023-02-07 10:37:00 +01:00
ninds <- nrow(seqs) # not sure if this should be nrow, ncols or length
2023-01-23 11:21:16 +01:00
data <- as.matrix(seqs)
2023-02-07 10:37:00 +01:00
newData <- matrix(-9, nrow = nrow(data), ncol = ncol(data))
2023-01-23 11:21:16 +01:00
newData[toupper(data) == 'A'] <- 1
newData[toupper(data) == 'C'] <- 2
newData[toupper(data) == 'G'] <- 3
newData[toupper(data) == 'T'] <- 4
2023-02-07 10:37:00 +01:00
data <- cbind(newData, seq(1, ninds))
2023-01-23 11:21:16 +01:00
return(list("ninds" = ninds, "data" = data, "heds" = heds))
}