diff --git a/DESCRIPTION b/DESCRIPTION index 53fcc4b..999125a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tbea Title: Tools for Pre- and Post-processing in Bayesian Evolutionary Analyses -Version: 0.5.2 +Version: 1.0.9000 Authors@R: c(person("Gustavo A.", "Ballen", email = "gaballench@gmail.com", role = c("aut", "cre")), person("Sandra", "Reinales", email = "spreinalesl@gmail.com", role = c("aut"))) Description: Package for bayesian inference in phylogenetics and evolution. @@ -10,11 +10,9 @@ Description: Package for bayesian inference in phylogenetics and evolution. platforms in evolutionary biology such as BEAST2. The package implements a way to measure similarity between probability density functions in the context of comparisons between prior and posterior bayesian - densities. It also provides functions for concatenating molecular and - morphological data for standard tree estimation (e.g., MrBayes) or total - evidence FBD divergence time estimation (e.g., Beast or RevBayes). + densities. Depends: R (>= 3.5.0) -Imports: ape, apex, Rfit, Hmisc, boot +Imports: ape, Rfit, Hmisc, boot License: file LICENSE Encoding: UTF-8 LazyData: true diff --git a/R/concatNexus.R b/R/concatNexus.R index bfe17cb..9dd9847 100644 --- a/R/concatNexus.R +++ b/R/concatNexus.R @@ -18,7 +18,7 @@ #' #' @author Gustavo A. Ballen #' -#' @details This function will concatenate matrices in nexus format (mandatory) and write to the disk the output and summary information on the partitions. It requires that the input matrices all share the same taxa in the same positions. The former is guaranteed by the function \code{fasta2nexus}, otherwise need to be carried out by the user, e.g., manually. The latter is kind of manual too as the morphological matrix is also expected to be manually generated by the user. This can be achieved by manually modifying the \code{wholeAlign.nex} file generated by \code{fasta2nexus}. +#' @details This function will concatenate matrices in nexus format (mandatory) and write to the disk the output and summary information on the partitions. It requires that the input matrices all share the same taxa in the same positions. #' #' @examples #' # Concatenate all the matrices in a given path, diff --git a/R/fasta2nexus.R b/R/fasta2nexus.R index c49f0ea..8dfbbbf 100644 --- a/R/fasta2nexus.R +++ b/R/fasta2nexus.R @@ -1,46 +1,16 @@ -#' fasta2nexus: Function for converting molecular alignments from fasta to nexus format +#' fasta2nexus (deprecated): Function for converting molecular alignments from fasta to nexus format #' -#' @param path A vector of type 'character' with the path to the fasta alignments. -#' -#' @param outpath A vector of type 'character' with the path to the nexus matrices. Defaults to NULL, so that the output files are written into the same directory declared in \code{path} -#' -#' @param pattern A vector of type 'character' with the string (also supports regular expressions) to be used as keyword for selecting the fasta files. The most basic case is to use ".fasta$" for a file ending with the extension ".fasta". -#' -#' @param wholeAlign Whether to fuse the fasta alignments into a concatenated molecular-only, continuous nexus matrix. Defaults to TRUE. +#' @param ... A placeholder for any argument that used to be in this function. #' -#' @return This function writes to the disk several files, at least one nexus originally from a fasta file, and potentially a concatenated file if several fasta are provided. +#' @return This function returns an error because it has been deprecated. #' #' @author Gustavo A. Ballen #' -#' @details This function will convert from fasta to nexus, and optionally concatenate a single nexus with the content of all fasta files. +#' @details This function was deprecated from tbea v1.0.0 onwards. For using this function please install tbea v0.5.0. #' -#' @examples -#' # Convert all fasta alignments into nexus matrices in a given path, -#' # with the output files in the same directory, for files -#' # ending with the pattern 'trimmed.nex'. -#' \dontrun{ -#' fasta2nexus(path = "sequences", outpath = NULL, pattern = "trimmed.fasta$", wholeAlign = TRUE) -#' } #' @export -fasta2nexus <- function(path, outpath = NULL, pattern, wholeAlign = TRUE) { - fastaFiles <- dir(path = path, pattern = pattern) - if (!is.null(outpath)){ - dir.create(outpath) - } else { - outpath <- path - } - # read all fastaFiles datasets - markers <- apex::read.multiFASTA(paste(path, fastaFiles, sep = "/")) - markers - if (wholeAlign) { - wholeAlignNexus <- apex::concatenate(markers) - ape::write.nexus.data(x = wholeAlignNexus, file = paste(outpath, "wholeAlign.nex", sep = "/"), interleaved = FALSE) - } - for (i in seq_along(markers@dna)) { - cat("Writing nexus dataset ", names(markers@dna[i]), "\n", sep = "") - ape::write.nexus.data(x = markers@dna[[i]], - file = paste(outpath, "/", names(markers@dna[i]), ".nex", sep = ""), - interleaved = FALSE) - } +fasta2nexus <- function(...) { + stop("The function fasta2nexus was deprecated from tbea v1.0.0 onwards. For using this function please install tbea v0.5.0\n") } + diff --git a/man/concatNexus.Rd b/man/concatNexus.Rd index c057892..0bea616 100644 --- a/man/concatNexus.Rd +++ b/man/concatNexus.Rd @@ -36,7 +36,7 @@ This function writes to the disk two files, one with the concatenated matrix and concatNexus: Function for concatenation of nexus matrices both morphological and molecular } \details{ -This function will concatenate matrices in nexus format (mandatory) and write to the disk the output and summary information on the partitions. It requires that the input matrices all share the same taxa in the same positions. The former is guaranteed by the function \code{fasta2nexus}, otherwise need to be carried out by the user, e.g., manually. The latter is kind of manual too as the morphological matrix is also expected to be manually generated by the user. This can be achieved by manually modifying the \code{wholeAlign.nex} file generated by \code{fasta2nexus}. +This function will concatenate matrices in nexus format (mandatory) and write to the disk the output and summary information on the partitions. It requires that the input matrices all share the same taxa in the same positions. } \examples{ # Concatenate all the matrices in a given path, diff --git a/man/fasta2nexus.Rd b/man/fasta2nexus.Rd index 94850bb..13e2ccf 100644 --- a/man/fasta2nexus.Rd +++ b/man/fasta2nexus.Rd @@ -2,35 +2,21 @@ % Please edit documentation in R/fasta2nexus.R \name{fasta2nexus} \alias{fasta2nexus} -\title{fasta2nexus: Function for converting molecular alignments from fasta to nexus format} +\title{fasta2nexus (deprecated): Function for converting molecular alignments from fasta to nexus format} \usage{ -fasta2nexus(path, outpath = NULL, pattern, wholeAlign = TRUE) +fasta2nexus(...) } \arguments{ -\item{path}{A vector of type 'character' with the path to the fasta alignments.} - -\item{outpath}{A vector of type 'character' with the path to the nexus matrices. Defaults to NULL, so that the output files are written into the same directory declared in \code{path}} - -\item{pattern}{A vector of type 'character' with the string (also supports regular expressions) to be used as keyword for selecting the fasta files. The most basic case is to use ".fasta$" for a file ending with the extension ".fasta".} - -\item{wholeAlign}{Whether to fuse the fasta alignments into a concatenated molecular-only, continuous nexus matrix. Defaults to TRUE.} +\item{...}{A placeholder for any argument that used to be in this function.} } \value{ -This function writes to the disk several files, at least one nexus originally from a fasta file, and potentially a concatenated file if several fasta are provided. +This function returns an error because it has been deprecated. } \description{ -fasta2nexus: Function for converting molecular alignments from fasta to nexus format +fasta2nexus (deprecated): Function for converting molecular alignments from fasta to nexus format } \details{ -This function will convert from fasta to nexus, and optionally concatenate a single nexus with the content of all fasta files. -} -\examples{ -# Convert all fasta alignments into nexus matrices in a given path, -# with the output files in the same directory, for files -# ending with the pattern 'trimmed.nex'. -\dontrun{ -fasta2nexus(path = "sequences", outpath = NULL, pattern = "trimmed.fasta$", wholeAlign = TRUE) -} +This function was deprecated from tbea v1.0.0 onwards. For using this function please install tbea v0.5.0. } \author{ Gustavo A. Ballen diff --git a/tests/testthat/test-fasta2nexus.R b/tests/testthat/test-fasta2nexus.R new file mode 100644 index 0000000..dd85336 --- /dev/null +++ b/tests/testthat/test-fasta2nexus.R @@ -0,0 +1,6 @@ + +test_that("fasta2nexus fails with a deprecation message", { + expect_error(fasta2nexus(), + regexp = "fasta2nexus was deprecated", + ignore.case = TRUE) +})