Skip to content

Commit

Permalink
Deprecated fasta2nexus and raised version number to 1.0.9000 as this …
Browse files Browse the repository at this point in the history
…is a breaking change in tbea 0.5.2 and older versions.
  • Loading branch information
gaballench committed Apr 20, 2023
1 parent 9810c89 commit add5edb
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 64 deletions.
8 changes: 3 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", role = c("aut", "cre")),
person("Sandra", "Reinales", email = "[email protected]", role = c("aut")))
Description: Package for bayesian inference in phylogenetics and evolution.
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/concatNexus.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
44 changes: 7 additions & 37 deletions R/fasta2nexus.R
Original file line number Diff line number Diff line change
@@ -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")
}

2 changes: 1 addition & 1 deletion man/concatNexus.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 6 additions & 20 deletions man/fasta2nexus.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tests/testthat/test-fasta2nexus.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

test_that("fasta2nexus fails with a deprecation message", {
expect_error(fasta2nexus(),
regexp = "fasta2nexus was deprecated",
ignore.case = TRUE)
})

0 comments on commit add5edb

Please sign in to comment.