diff --git a/.Rbuildignore b/.Rbuildignore index 8a8a9deb..802417e3 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -12,3 +12,5 @@ ^scripts$ ^\.appveyor\.yml$ ^doc$ +^created\.xml$ +^expected\.xml$ diff --git a/DESCRIPTION b/DESCRIPTION index b9690882..816dc468 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: beautier Title: 'BEAUti' from R -Version: 2.5.2 +Version: 2.6 Authors@R: c( person("Richèl J.C.", "Bilderbeek", email = "richel@richelbilderbeek.nl", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1107-7049")), person("Joëlle", "Barido-Sottani", role = "rev", comment = "Joëlle reviewed the package for rOpenSci, see https://github.com/ropensci/onboarding/issues/209"), diff --git a/NEWS.md b/NEWS.md index e674e2cf..fe3081bd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,24 @@ Newest versions at top. +## beautier 2.6 (2021-05-22) + +### NEW FEATURES + + * None + +### MINOR IMPROVEMENTS + + * Make sure that no files are created in `~/.cache` + +### BUG FIXES + + * None + +### DEPRECATED AND DEFUNCT + + * None + ## beautier 2.5.2 (2021-05-22) ### NEW FEATURES diff --git a/R/beautier.R b/R/beautier.R index 6c0e8be2..ff260f95 100644 --- a/R/beautier.R +++ b/R/beautier.R @@ -13,7 +13,7 @@ #' input_filename <- get_fasta_filename() #' #' # The file created by beautier, a BEAST2 input file -#' output_filename <- tempfile() +#' output_filename <- get_beautier_tempfilename() #' #' # Use the default BEAUti settings to create a BEAST2 input file #' create_beast2_input_file_from_model( @@ -21,6 +21,7 @@ #' output_filename, #' inference_model = create_inference_model() #' ) +#' file.remove(output_filename) #' @seealso #' These are packages associated with \code{beautier}: #' \itemize{ diff --git a/R/create_beast2_input_file.R b/R/create_beast2_input_file.R index f8c4e211..997009de 100644 --- a/R/create_beast2_input_file.R +++ b/R/create_beast2_input_file.R @@ -6,12 +6,13 @@ #' input_filename <- get_fasta_filename() #' #' # The file created by beautier, a BEAST2 input file -#' output_filename <- tempfile(pattern = "beast2", fileext = ".xml") +#' output_filename <- get_beautier_tempfilename() #' #' create_beast2_input_file( #' input_filename, #' output_filename #' ) +#' file.remove(output_filename) #' @author Richèl J.C. Bilderbeek #' @seealso #' Use \link{create_beast2_input_file_from_model} to do the same with an diff --git a/R/create_beast2_input_file_from_model.R b/R/create_beast2_input_file_from_model.R index fa2de802..6a94825c 100644 --- a/R/create_beast2_input_file_from_model.R +++ b/R/create_beast2_input_file_from_model.R @@ -4,11 +4,13 @@ #' @seealso use \link{create_beast2_input_from_model} to #' get the BEAST2 input file as text #' @examples +#' output_filename <- get_beautier_tempfilename() #' create_beast2_input_file_from_model( #' input_filename = get_fasta_filename(), -#' output_filename = tempfile(), +#' output_filename = output_filename, #' inference_model = create_inference_model() #' ) +#' file.remove(output_filename) #' @author Richèl J.C. Bilderbeek #' @seealso #' See \code{\link{create_site_model}} for examples with diff --git a/R/create_clock_model.R b/R/create_clock_model.R index 09187aca..e8065245 100644 --- a/R/create_clock_model.R +++ b/R/create_clock_model.R @@ -15,25 +15,25 @@ #' model, see \code{\link{create_strict_clock_model}}. #' @author Richèl J.C. Bilderbeek #' @examples -#' rln_clock_model <- create_rln_clock_model() +#' rln_clock_model <- create_rln_clock_model() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' get_fasta_filename(), -#' beast2_input_file, -#' clock_model = rln_clock_model -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' get_fasta_filename(), +#' beast2_input_file, +#' clock_model = rln_clock_model +#' ) +#' file.remove(beast2_input_file) #' -#' strict_clock_model <- create_strict_clock_model() +#' strict_clock_model <- create_strict_clock_model() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' get_fasta_filename(), -#' beast2_input_file, -#' clock_model = strict_clock_model -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' get_fasta_filename(), +#' beast2_input_file, +#' clock_model = strict_clock_model +#' ) +#' file.remove(beast2_input_file) #' @export create_clock_model <- function( name, @@ -80,27 +80,27 @@ create_clock_model <- function( #' @return a relaxed log-normal clock_model #' @author Richèl J.C. Bilderbeek #' @examples -#' rln_clock_model <- create_rln_clock_model() +#' rln_clock_model <- create_rln_clock_model() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' get_fasta_filename(), -#' beast2_input_file, -#' clock_model = rln_clock_model -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' get_fasta_filename(), +#' beast2_input_file, +#' clock_model = rln_clock_model +#' ) +#' file.remove(beast2_input_file) #' -#' rln_clock_model_exp <- create_rln_clock_model( -#' mean_rate_prior_distr = create_exp_distr() -#' ) +#' rln_clock_model_exp <- create_rln_clock_model( +#' mean_rate_prior_distr = create_exp_distr() +#' ) #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' get_fasta_filename(), -#' beast2_input_file, -#' clock_model = rln_clock_model_exp -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' get_fasta_filename(), +#' beast2_input_file, +#' clock_model = rln_clock_model_exp +#' ) +#' file.remove(beast2_input_file) #' @aliases create_rln_clock_model create_clock_model_rln #' @export create_rln_clock_model create_clock_model_rln create_rln_clock_model <- create_clock_model_rln <- function( @@ -139,30 +139,30 @@ create_rln_clock_model <- create_clock_model_rln <- function( #' @return a strict clock_model #' @author Richèl J.C. Bilderbeek #' @examples -#' strict_clock_model <- create_strict_clock_model( -#' clock_rate_param = 1.0, -#' clock_rate_distr = create_uniform_distr() -#' ) +#' strict_clock_model <- create_strict_clock_model( +#' clock_rate_param = 1.0, +#' clock_rate_distr = create_uniform_distr() +#' ) #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' get_fasta_filename(), -#' beast2_input_file, -#' clock_model = strict_clock_model -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' get_fasta_filename(), +#' beast2_input_file, +#' clock_model = strict_clock_model +#' ) +#' file.remove(beast2_input_file) #' -#' strict_clock_model_gamma <- create_strict_clock_model( -#' clock_rate_distr = create_gamma_distr() -#' ) +#' strict_clock_model_gamma <- create_strict_clock_model( +#' clock_rate_distr = create_gamma_distr() +#' ) #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' get_fasta_filename(), -#' beast2_input_file, -#' clock_model = strict_clock_model_gamma -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' get_fasta_filename(), +#' beast2_input_file, +#' clock_model = strict_clock_model_gamma +#' ) +#' file.remove(beast2_input_file) #' @aliases create_strict_clock_model create_clock_model_strict #' @export create_strict_clock_model create_clock_model_strict create_strict_clock_model <- create_clock_model_strict <- function( diff --git a/R/create_distr.R b/R/create_distr.R index 4260f5a7..652db838 100644 --- a/R/create_distr.R +++ b/R/create_distr.R @@ -33,18 +33,18 @@ #' and \code{\link{create_uniform_distr}} #' for examples how to use those distributions #' @examples -#' # Use any distribution -#' distr <- create_beta_distr() +#' # Use any distribution +#' distr <- create_beta_distr() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = distr -#' ) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @author Richèl J.C. Bilderbeek #' @export create_distr <- function( @@ -100,17 +100,17 @@ create_distr <- function( #' of all supported distributions #' @author Richèl J.C. Bilderbeek #' @examples -#' beta_distr <- create_beta_distr() +#' beta_distr <- create_beta_distr() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = beta_distr -#' ) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = beta_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_beta_distr create_distr_beta #' @export create_beta_distr create_distr_beta create_beta_distr <- create_distr_beta <- function( @@ -163,17 +163,17 @@ create_beta_distr <- create_distr_beta <- function( #' of all supported distributions #' @author Richèl J.C. Bilderbeek #' @examples -#' exp_distr <- create_exp_distr() +#' exp_distr <- create_exp_distr() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = exp_distr -#' ) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = exp_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_exp_distr create_distr_exp #' @export create_exp_distr create_distr_exp create_exp_distr <- create_distr_exp <- function( @@ -215,22 +215,22 @@ create_exp_distr <- create_distr_exp <- function( #' of all supported distributions #' @author Richèl J.C. Bilderbeek #' @examples -#' gamma_distr <- create_gamma_distr( -#' alpha = 0.05, -#' beta = 10.0 -#' ) +#' gamma_distr <- create_gamma_distr( +#' alpha = 0.05, +#' beta = 10.0 +#' ) #' -#' gtr_site_model <- create_gtr_site_model( -#' rate_ac_prior_distr = gamma_distr -#' ) +#' gtr_site_model <- create_gtr_site_model( +#' rate_ac_prior_distr = gamma_distr +#' ) #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' site_model = gtr_site_model -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' site_model = gtr_site_model +#' ) +#' file.remove(beast2_input_file) #' @aliases create_gamma_distr create_distr_gamma #' @export create_gamma_distr create_distr_gamma create_gamma_distr <- create_distr_gamma <- function( @@ -288,17 +288,17 @@ create_gamma_distr <- create_distr_gamma <- function( #' of all supported distributions #' @author Richèl J.C. Bilderbeek #' @examples -#' inv_gamma_distr <- create_inv_gamma_distr() +#' inv_gamma_distr <- create_inv_gamma_distr() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = inv_gamma_distr -#' ) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = inv_gamma_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_inv_gamma_distr create_distr_inv_gamma #' @export create_inv_gamma_distr create_distr_inv_gamma create_inv_gamma_distr <- create_distr_inv_gamma <- function( @@ -349,17 +349,17 @@ create_inv_gamma_distr <- create_distr_inv_gamma <- function( #' of all supported distributions #' @author Richèl J.C. Bilderbeek #' @examples -#' laplace_distr <- create_laplace_distr() +#' laplace_distr <- create_laplace_distr() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = laplace_distr -#' ) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = laplace_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_laplace_distr create_distr_laplace #' @export create_laplace_distr create_distr_laplace create_laplace_distr <- create_distr_laplace <- function( @@ -411,17 +411,17 @@ create_laplace_distr <- create_distr_laplace <- function( #' of all supported distributions #' @author Richèl J.C. Bilderbeek #' @examples -#' log_normal_distr <- create_log_normal_distr() +#' log_normal_distr <- create_log_normal_distr() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = log_normal_distr -#' ) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = log_normal_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_log_normal_distr create_distr_log_normal #' @export create_log_normal_distr create_distr_log_normal create_log_normal_distr <- create_distr_log_normal <- function( @@ -473,17 +473,17 @@ create_log_normal_distr <- create_distr_log_normal <- function( #' of all supported distributions #' @author Richèl J.C. Bilderbeek #' @examples -#' normal_distr <- create_normal_distr() +#' normal_distr <- create_normal_distr() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = normal_distr -#' ) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = normal_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_normal_distr create_distr_normal #' @export create_normal_distr create_distr_normal create_normal_distr <- create_distr_normal <- function( @@ -527,17 +527,17 @@ create_normal_distr <- create_distr_normal <- function( #' of all supported distributions #' @author Richèl J.C. Bilderbeek #' @examples -#' one_div_x_distr <- create_one_div_x_distr() +#' one_div_x_distr <- create_one_div_x_distr() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = one_div_x_distr -#' ) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = one_div_x_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_one_div_x_distr create_distr_one_div_x #' @export create_one_div_x_distr create_distr_one_div_x create_one_div_x_distr <- create_distr_one_div_x <- function( @@ -566,17 +566,17 @@ create_one_div_x_distr <- create_distr_one_div_x <- function( #' of all supported distributions #' @author Richèl J.C. Bilderbeek #' @examples -#' poisson_distr <- create_poisson_distr() +#' poisson_distr <- create_poisson_distr() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = poisson_distr -#' ) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = poisson_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_poisson_distr create_distr_poisson #' @export create_poisson_distr create_distr_poisson create_poisson_distr <- create_distr_poisson <- function( @@ -611,17 +611,17 @@ create_poisson_distr <- create_distr_poisson <- function( #' of all supported distributions #' @author Richèl J.C. Bilderbeek #' @examples -#' uniform_distr <- create_uniform_distr() +#' uniform_distr <- create_uniform_distr() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = uniform_distr -#' ) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = uniform_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_uniform_distr create_distr_uniform #' @export create_uniform_distr create_distr_uniform create_uniform_distr <- create_distr_uniform <- function( diff --git a/R/create_gamma_site_model.R b/R/create_gamma_site_model.R index 5146ba99..f22769e5 100644 --- a/R/create_gamma_site_model.R +++ b/R/create_gamma_site_model.R @@ -20,17 +20,17 @@ #' @seealso Use \code{\link{create_gamma_site_model}} #' to create a gamma site model #' @examples -#' gamma_site_model <- create_gamma_site_model(prop_invariant = 0.5) +#' gamma_site_model <- create_gamma_site_model(prop_invariant = 0.5) #' -#' site_model <- create_hky_site_model(gamma_site_model = gamma_site_model) +#' site_model <- create_hky_site_model(gamma_site_model = gamma_site_model) #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' get_fasta_filename(), -#' beast2_input_file, -#' site_model = site_model -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' get_fasta_filename(), +#' beast2_input_file, +#' site_model = site_model +#' ) +#' file.remove(beast2_input_file) #' @author Richèl J.C. Bilderbeek #' @export create_gamma_site_model <- function( diff --git a/R/create_inference_model.R b/R/create_inference_model.R index fb33ae37..c05c5467 100644 --- a/R/create_inference_model.R +++ b/R/create_inference_model.R @@ -17,11 +17,13 @@ #' mcmc = create_mcmc(chain_length = 50000, store_every = 1000) #' ) #' +#' output_filename <- get_beautier_tempfilename() #' create_beast2_input_file_from_model( #' input_filename = get_fasta_filename(), -#' output_filename = tempfile(fileext = ".xml"), +#' output_filename = output_filename, #' inference_model = inference_model #' ) +#' file.remove(beast2_input_file) #' @export create_inference_model <- function( site_model = beautier::create_jc69_site_model(), diff --git a/R/create_mcmc.R b/R/create_mcmc.R index 6d47671e..f0785f08 100644 --- a/R/create_mcmc.R +++ b/R/create_mcmc.R @@ -24,16 +24,16 @@ #' Use \code{\link{rename_mcmc_filenames}} to rename the filenames in an MCMC. #' @author Richèl J.C. Bilderbeek #' @examples -#' #' # Create an MCMC chain with 50 states #' mcmc <- create_mcmc(chain_length = 50000, store_every = 1000) #' -#' beast2_input_file <- tempfile() +#' beast2_input_file <- get_beautier_tempfilename() #' create_beast2_input_file( #' get_fasta_filename(), #' beast2_input_file, #' mcmc = mcmc #' ) +#' file.remove(beast2_input_file) #' @export create_mcmc <- function( chain_length = 10000000, diff --git a/R/create_mcmc_nested_sampling.R b/R/create_mcmc_nested_sampling.R index 5e2fffd2..76dc28b1 100644 --- a/R/create_mcmc_nested_sampling.R +++ b/R/create_mcmc_nested_sampling.R @@ -17,21 +17,21 @@ #' with, among others, a short MCMC chain length. #' Use \code{\link{check_ns_mcmc}} to check that an NS MCMC object is valid. #' @examples -#' mcmc <- create_ns_mcmc( -#' chain_length = 1e7, -#' store_every = 1000, -#' particle_count = 1, -#' sub_chain_length = 1000, -#' epsilon = 1e-12 -#' ) +#' mcmc <- create_ns_mcmc( +#' chain_length = 1e7, +#' store_every = 1000, +#' particle_count = 1, +#' sub_chain_length = 1000, +#' epsilon = 1e-12 +#' ) #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' get_fasta_filename(), -#' beast2_input_file, -#' mcmc = mcmc -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' get_fasta_filename(), +#' beast2_input_file, +#' mcmc = mcmc +#' ) +#' file.remove(beast2_input_file) #' @references #' * [1] Patricio Maturana Russel, Brendon J Brewer, Steffen Klaere, #' Remco R Bouckaert; Model Selection and Parameter Inference in diff --git a/R/create_param.R b/R/create_param.R index ee5c3e7c..4674942c 100644 --- a/R/create_param.R +++ b/R/create_param.R @@ -23,24 +23,24 @@ #' @return a parameter #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create an alpha parameter -#' alpha_param <- create_alpha_param() +#' # Create an alpha parameter +#' alpha_param <- create_alpha_param() #' -#' # Use the parameter in a distribution -#' beta_distr <- create_beta_distr( -#' alpha = alpha_param -#' ) +#' # Use the parameter in a distribution +#' beta_distr <- create_beta_distr( +#' alpha = alpha_param +#' ) #' -#' # Use the distribution to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = beta_distr -#' ) +#' # Use the distribution to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = beta_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @export create_param <- function( name, @@ -85,24 +85,24 @@ create_param <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create the parameter -#' alpha_param <- create_alpha_param() +#' # Create the parameter +#' alpha_param <- create_alpha_param() #' -#' # Use the parameter in a distribution -#' beta_distr <- create_beta_distr( -#' alpha = alpha_param -#' ) +#' # Use the parameter in a distribution +#' beta_distr <- create_beta_distr( +#' alpha = alpha_param +#' ) #' -#' # Use the distribution to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = beta_distr -#' ) +#' # Use the distribution to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = beta_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_alpha_param create_param_alpha #' @export create_alpha_param create_param_alpha create_alpha_param <- create_param_alpha <- function( @@ -131,24 +131,24 @@ create_alpha_param <- create_param_alpha <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create the parameter -#' beta_param <- create_beta_param() +#' # Create the parameter +#' beta_param <- create_beta_param() #' -#' # Use the parameter in a distribution -#' gamma_distr <- create_gamma_distr( -#' beta = beta_param -#' ) +#' # Use the parameter in a distribution +#' gamma_distr <- create_gamma_distr( +#' beta = beta_param +#' ) #' -#' # Use the distribution to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = gamma_distr -#' ) +#' # Use the distribution to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = gamma_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_beta_param create_param_beta #' @export create_beta_param create_param_beta create_beta_param <- create_param_beta <- function( @@ -172,23 +172,23 @@ create_beta_param <- create_param_beta <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' clock_rate_param <- create_clock_rate_param( -#' id = "anthus_aco", value = 1.0 -#' ) +#' clock_rate_param <- create_clock_rate_param( +#' id = "anthus_aco", value = 1.0 +#' ) #' -#' # Use the parameter in a clock model -#' strict_clock_model <- create_strict_clock_model( -#' clock_rate_param = clock_rate_param -#' ) +#' # Use the parameter in a clock model +#' strict_clock_model <- create_strict_clock_model( +#' clock_rate_param = clock_rate_param +#' ) #' -#' # Use the distribution to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' clock_model = strict_clock_model -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' # Use the distribution to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' clock_model = strict_clock_model +#' ) +#' file.remove(beast2_input_file) #' @aliases create_clock_rate_param create_param_clock_rate #' @export create_clock_rate_param create_param_clock_rate create_clock_rate_param <- create_param_clock_rate <- function( @@ -254,24 +254,24 @@ create_kappa_2_param <- create_param_kappa_2 <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create the parameter -#' lambda_param <- create_lambda_param() +#' # Create the parameter +#' lambda_param <- create_lambda_param() #' -#' # Use the parameter in a distribution -#' poisson_distr <- create_poisson_distr( -#' lambda = lambda_param -#' ) +#' # Use the parameter in a distribution +#' poisson_distr <- create_poisson_distr( +#' lambda = lambda_param +#' ) #' -#' # Use the distribution to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = poisson_distr -#' ) +#' # Use the distribution to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = poisson_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_lambda_param create_param_lambda #' @export create_lambda_param create_param_lambda create_lambda_param <- create_param_lambda <- function( @@ -295,24 +295,24 @@ create_lambda_param <- create_param_lambda <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create the parameter -#' m_param <- create_m_param() +#' # Create the parameter +#' m_param <- create_m_param() #' -#' # Use the parameter in a distribution -#' log_normal_distr <- create_log_normal_distr( -#' m = m_param -#' ) +#' # Use the parameter in a distribution +#' log_normal_distr <- create_log_normal_distr( +#' m = m_param +#' ) #' -#' # Use the distribution to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = log_normal_distr -#' ) +#' # Use the distribution to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = log_normal_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_m_param create_param_m #' @export create_m_param create_param_m create_m_param <- create_param_m <- function( @@ -339,24 +339,24 @@ create_m_param <- create_param_m <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create the parameter -#' mean_param <- create_mean_param(value = 1.0) +#' # Create the parameter +#' mean_param <- create_mean_param(value = 1.0) #' -#' # Use the parameter in a distribution -#' exp_distr <- create_exp_distr( -#' mean = mean_param -#' ) +#' # Use the parameter in a distribution +#' exp_distr <- create_exp_distr( +#' mean = mean_param +#' ) #' -#' # Use the distribution to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = exp_distr -#' ) +#' # Use the distribution to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = exp_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_mean_param create_param_mean #' @export create_mean_param create_param_mean create_mean_param <- create_param_mean <- function( @@ -381,24 +381,24 @@ create_mean_param <- create_param_mean <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create the parameter -#' mu_param <- create_mu_param() +#' # Create the parameter +#' mu_param <- create_mu_param() #' -#' # Use the parameter in a distribution -#' laplace_distr <- create_laplace_distr( -#' mu = mu_param -#' ) +#' # Use the parameter in a distribution +#' laplace_distr <- create_laplace_distr( +#' mu = mu_param +#' ) #' -#' # Use the distribution to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = laplace_distr -#' ) +#' # Use the distribution to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = laplace_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_mu_param create_param_mu #' @export create_mu_param create_param_mu create_mu_param <- create_param_mu <- function( @@ -420,19 +420,19 @@ create_mu_param <- create_param_mu <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create parameter -#' rate_ac_param <- create_rate_ac_param(value = 1, estimate = FALSE) +#' # Create parameter +#' rate_ac_param <- create_rate_ac_param(value = 1, estimate = FALSE) #' -#' # Use the parameter to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' site_model = create_gtr_site_model( -#' rate_ac_param = rate_ac_param -#' ) +#' # Use the parameter to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' site_model = create_gtr_site_model( +#' rate_ac_param = rate_ac_param #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_rate_ac_param create_param_rate_ac #' @export create_rate_ac_param create_param_rate_ac create_rate_ac_param <- create_param_rate_ac <- function( @@ -457,19 +457,19 @@ create_rate_ac_param <- create_param_rate_ac <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create parameter -#' rate_ag_param <- create_rate_ag_param(value = 1, estimate = FALSE) +#' # Create parameter +#' rate_ag_param <- create_rate_ag_param(value = 1, estimate = FALSE) #' -#' # Use the parameter to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' site_model = create_gtr_site_model( -#' rate_ag_param = rate_ag_param -#' ) +#' # Use the parameter to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' site_model = create_gtr_site_model( +#' rate_ag_param = rate_ag_param #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_rate_ag_param create_param_rate_ag #' @export create_rate_ag_param create_param_rate_ag create_rate_ag_param <- create_param_rate_ag <- function( @@ -494,19 +494,19 @@ create_rate_ag_param <- create_param_rate_ag <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create parameter -#' rate_at_param <- create_rate_at_param(value = 1, estimate = FALSE) +#' # Create parameter +#' rate_at_param <- create_rate_at_param(value = 1, estimate = FALSE) #' -#' # Use the parameter to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' site_model = create_gtr_site_model( -#' rate_at_param = rate_at_param -#' ) +#' # Use the parameter to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' site_model = create_gtr_site_model( +#' rate_at_param = rate_at_param #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_rate_at_param create_param_rate_at #' @export create_rate_at_param create_param_rate_at create_rate_at_param <- create_param_rate_at <- function( @@ -531,19 +531,19 @@ create_rate_at_param <- create_param_rate_at <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create parameter -#' rate_cg_param <- create_rate_cg_param(value = 1, estimate = FALSE) +#' # Create parameter +#' rate_cg_param <- create_rate_cg_param(value = 1, estimate = FALSE) #' -#' # Use the parameter to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' site_model = create_gtr_site_model( -#' rate_cg_param = rate_cg_param -#' ) +#' # Use the parameter to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' site_model = create_gtr_site_model( +#' rate_cg_param = rate_cg_param #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_rate_cg_param create_param_rate_cg #' @export create_rate_cg_param create_param_rate_cg create_rate_cg_param <- create_param_rate_cg <- function( @@ -568,19 +568,19 @@ create_rate_cg_param <- create_param_rate_cg <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create parameter -#' rate_ct_param <- create_rate_ct_param(value = 1) +#' # Create parameter +#' rate_ct_param <- create_rate_ct_param(value = 1) #' -#' # Use the parameter to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' site_model = create_gtr_site_model( -#' rate_ct_param = rate_ct_param -#' ) +#' # Use the parameter to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' site_model = create_gtr_site_model( +#' rate_ct_param = rate_ct_param #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_rate_ct_param create_param_rate_ct #' @export create_rate_ct_param create_param_rate_ct create_rate_ct_param <- create_param_rate_ct <- function( @@ -604,19 +604,19 @@ create_rate_ct_param <- create_param_rate_ct <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create parameter -#' rate_gt_param <- create_rate_gt_param(value = 1, estimate = FALSE) +#' # Create parameter +#' rate_gt_param <- create_rate_gt_param(value = 1, estimate = FALSE) #' -#' # Use the parameter to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' site_model = create_gtr_site_model( -#' rate_gt_param = rate_gt_param -#' ) +#' # Use the parameter to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' site_model = create_gtr_site_model( +#' rate_gt_param = rate_gt_param #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_rate_gt_param create_param_rate_gt #' @export create_rate_gt_param create_param_rate_gt create_rate_gt_param <- create_param_rate_gt <- function( @@ -643,24 +643,24 @@ create_rate_gt_param <- create_param_rate_gt <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create the parameter -#' s_param <- create_s_param() +#' # Create the parameter +#' s_param <- create_s_param() #' -#' # Use the parameter in a distribution -#' log_normal_distr <- create_log_normal_distr( -#' s = s_param -#' ) +#' # Use the parameter in a distribution +#' log_normal_distr <- create_log_normal_distr( +#' s = s_param +#' ) #' -#' # Use the distribution to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = log_normal_distr -#' ) +#' # Use the distribution to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = log_normal_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_s_param create_param_s #' @export create_s_param create_param_s create_s_param <- create_param_s <- function( @@ -689,24 +689,24 @@ create_s_param <- create_param_s <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create the parameter -#' scale_param <- create_scale_param() +#' # Create the parameter +#' scale_param <- create_scale_param() #' -#' # Use the parameter in a distribution -#' laplace_distr <- create_laplace_distr( -#' scale = scale_param -#' ) +#' # Use the parameter in a distribution +#' laplace_distr <- create_laplace_distr( +#' scale = scale_param +#' ) #' -#' # Use the distribution to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = laplace_distr -#' ) +#' # Use the distribution to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = laplace_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_scale_param create_param_scale #' @export create_scale_param create_param_scale create_scale_param <- create_param_scale <- function( @@ -731,24 +731,24 @@ create_scale_param <- create_param_scale <- function( #' of all parameters that can be created #' @author Richèl J.C. Bilderbeek #' @examples -#' # Create the parameter -#' sigma_param <- create_sigma_param() +#' # Create the parameter +#' sigma_param <- create_sigma_param() #' -#' # Use the parameter in a distribution -#' normal_distr <- create_normal_distr( -#' sigma = sigma_param -#' ) +#' # Use the parameter in a distribution +#' normal_distr <- create_normal_distr( +#' sigma = sigma_param +#' ) #' -#' # Use the distribution to create a BEAST2 input file -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior( -#' birth_rate_distr = normal_distr -#' ) +#' # Use the distribution to create a BEAST2 input file +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior( +#' birth_rate_distr = normal_distr #' ) -#' testit::assert(file.exists(beast2_input_file)) +#' ) +#' file.remove(beast2_input_file) #' @aliases create_sigma_param create_param_sigma #' @export create_sigma_param create_param_sigma create_sigma_param <- create_param_sigma <- function( diff --git a/R/create_site_model.R b/R/create_site_model.R index 20b8cd4d..c07111ca 100644 --- a/R/create_site_model.R +++ b/R/create_site_model.R @@ -24,36 +24,40 @@ #' input_filename <- get_fasta_filename() #' #' # GTR -#' output_filename <- tempfile(pattern = "example_gtr", fileext = ".xml") +#' output_filename <- get_beautier_tempfilename() #' create_beast2_input_file( #' input_filename = input_filename, #' output_filename = output_filename, #' site_model = create_gtr_site_model() #' ) +#' file.remove(output_filename) #' #' # HKY -#' output_filename <- tempfile(pattern = "example_hky", fileext = ".xml") +#' output_filename <- get_beautier_tempfilename() #' create_beast2_input_file( #' input_filename = input_filename, #' output_filename = output_filename, #' site_model = create_hky_site_model() #' ) +#' file.remove(output_filename) #' #' # JC69 -#' output_filename <- tempfile(pattern = "example_jc69", fileext = ".xml") +#' output_filename <- get_beautier_tempfilename() #' create_beast2_input_file( #' input_filename = input_filename, #' output_filename = output_filename, #' site_model = create_jc69_site_model() #' ) +#' file.remove(output_filename) #' #' # TN93 -#' output_filename <- tempfile(pattern = "example_tn93", fileext = ".xml") +#' output_filename <- get_beautier_tempfilename() #' create_beast2_input_file( #' input_filename = input_filename, #' output_filename = output_filename, #' site_model = create_tn93_site_model() #' ) +#' file.remove(output_filename) #' @export create_site_model <- function( name, @@ -128,22 +132,22 @@ create_site_model <- function( #' @return a GTR site_model #' @author Richèl J.C. Bilderbeek #' @examples -#' gtr_site_model <- create_gtr_site_model( -#' rate_ac_param = 1.2, -#' rate_ag_param = 2.3, -#' rate_at_param = 3.4, -#' rate_cg_param = 4.5, -#' rate_ct_param = 5.6, -#' rate_gt_param = 6.7 -#' ) +#' gtr_site_model <- create_gtr_site_model( +#' rate_ac_param = 1.2, +#' rate_ag_param = 2.3, +#' rate_at_param = 3.4, +#' rate_cg_param = 4.5, +#' rate_ct_param = 5.6, +#' rate_gt_param = 6.7 +#' ) #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' site_model = gtr_site_model -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' site_model = gtr_site_model +#' ) +#' file.remove(beast2_input_file) #' @aliases create_gtr_site_model create_site_model_gtr #' @export create_gtr_site_model create_site_model_gtr create_gtr_site_model <- create_site_model_gtr <- function( @@ -233,12 +237,13 @@ create_gtr_site_model <- create_site_model_gtr <- function( #' @author Richèl J.C. Bilderbeek #' @examples #' hky_site_model <- create_hky_site_model() -#' +#' output_filename <- get_beautier_tempfilename() #' create_beast2_input_file( #' input_filename = get_fasta_filename(), -#' output_filename = tempfile(pattern = "beast", fileext = ".xml"), +#' output_filename = output_filename, #' site_model = hky_site_model #' ) +#' file.remove(output_filename) #' @aliases create_hky_site_model create_site_model_hky #' @export create_hky_site_model create_site_model_hky create_hky_site_model <- create_site_model_hky <- function( @@ -268,11 +273,13 @@ create_hky_site_model <- create_site_model_hky <- function( #' @examples #' jc69_site_model <- create_jc69_site_model() #' +#' output_filename <- get_beautier_tempfilename() #' create_beast2_input_file( #' input_filename = get_fasta_filename(), -#' output_filename = tempfile(pattern = "beast", fileext = ".xml"), +#' output_filename = output_filename, #' site_model = jc69_site_model #' ) +#' file.remove(output_filename) #' @aliases create_jc69_site_model create_site_model_jc69 #' @export create_jc69_site_model create_site_model_jc69 create_jc69_site_model <- create_site_model_jc69 <- function( @@ -316,11 +323,13 @@ create_jc69_site_model <- create_site_model_jc69 <- function( #' kappa_2_param = 2.0 #' ) #' +#' output_filename <- get_beautier_tempfilename() #' create_beast2_input_file( #' input_filename = get_fasta_filename(), -#' output_filename = tempfile(pattern = "beast", fileext = ".xml"), +#' output_filename = output_filename, #' site_model = tn93_site_model #' ) +#' file.remove(output_filename) #' @aliases create_tn93_site_model create_site_model_tn93 #' @export create_tn93_site_model create_site_model_tn93 create_tn93_site_model <- create_site_model_tn93 <- function( diff --git a/R/create_temp_screenlog_filename.R b/R/create_temp_screenlog_filename.R index 73272dae..3b8eb322 100644 --- a/R/create_temp_screenlog_filename.R +++ b/R/create_temp_screenlog_filename.R @@ -4,9 +4,8 @@ #' @export create_temp_screenlog_filename <- function() { normalizePath( - tempfile( + get_beautier_tempfilename( pattern = "screenlog_", - tmpdir = rappdirs::user_cache_dir(), fileext = ".csv" ), mustWork = FALSE diff --git a/R/create_temp_tracelog_filename.R b/R/create_temp_tracelog_filename.R index e7021ae8..acf3de08 100644 --- a/R/create_temp_tracelog_filename.R +++ b/R/create_temp_tracelog_filename.R @@ -4,9 +4,8 @@ #' @export create_temp_tracelog_filename <- function() { normalizePath( - tempfile( + get_beautier_tempfilename( pattern = "tracelog_", - tmpdir = rappdirs::user_cache_dir(), fileext = ".log" ), mustWork = FALSE diff --git a/R/create_temp_treelog_filename.R b/R/create_temp_treelog_filename.R index c5d6a842..144e5152 100644 --- a/R/create_temp_treelog_filename.R +++ b/R/create_temp_treelog_filename.R @@ -4,9 +4,8 @@ #' @export create_temp_treelog_filename <- function() { normalizePath( - tempfile( + get_beautier_tempfilename( pattern = "treelog_", - tmpdir = rappdirs::user_cache_dir(), fileext = ".trees" ), mustWork = FALSE diff --git a/R/create_test_inference_model.R b/R/create_test_inference_model.R index 320d2361..8d012d9a 100644 --- a/R/create_test_inference_model.R +++ b/R/create_test_inference_model.R @@ -14,12 +14,13 @@ #' @examples #' inference_model <- create_test_inference_model() #' -#' beast2_input_file <- tempfile(fileext = ".xml") +#' beast2_input_file <- get_beautier_tempfilename() #' create_beast2_input_file_from_model( #' get_fasta_filename(), #' beast2_input_file, #' inference_model = inference_model #' ) +#' file.remove(beast2_input_file) #' @export create_test_inference_model <- function( site_model = beautier::create_jc69_site_model(), diff --git a/R/create_test_mcmc.R b/R/create_test_mcmc.R index 621d0ded..0576ce11 100644 --- a/R/create_test_mcmc.R +++ b/R/create_test_mcmc.R @@ -8,12 +8,13 @@ #' # Create an MCMC chain with 50 states #' mcmc <- create_test_mcmc() #' -#' beast2_input_file <- tempfile(fileext = ".xml") +#' beast2_input_file <- get_beautier_tempfilename() #' create_beast2_input_file( #' get_fasta_filename(), #' beast2_input_file, #' mcmc = mcmc #' ) +#' file.remove(beast2_input_file) #' @export create_test_mcmc <- function( chain_length = 3000, diff --git a/R/create_test_ns_mcmc.R b/R/create_test_ns_mcmc.R index b716a7f6..1a50bfbe 100644 --- a/R/create_test_ns_mcmc.R +++ b/R/create_test_ns_mcmc.R @@ -8,16 +8,14 @@ #' @seealso Use \code{\link{create_ns_mcmc}} to create a default #' nested sampling MCMC #' @examples -#' #' mcmc <- create_test_ns_mcmc() -#' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' +#' beast2_input_file <- get_beautier_tempfilename() #' create_beast2_input_file( #' get_fasta_filename(), #' beast2_input_file, #' mcmc = mcmc #' ) +#' file.remove(beast2_input_file) #' @author Richèl J.C. Bilderbeek #' @export create_test_ns_mcmc <- function( diff --git a/R/create_tree_prior.R b/R/create_tree_prior.R index 63fef7c4..6cc36348 100644 --- a/R/create_tree_prior.R +++ b/R/create_tree_prior.R @@ -20,45 +20,45 @@ #' for more examples using those functions #' @author Richèl J.C. Bilderbeek #' @examples -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_bd_tree_prior() -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_bd_tree_prior() +#' ) +#' file.remove(beast2_input_file) #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_beautier_path("test_output_6.fas"), -#' beast2_input_file, -#' tree_prior = create_cbs_tree_prior() -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_beautier_path("test_output_6.fas"), +#' beast2_input_file, +#' tree_prior = create_cbs_tree_prior() +#' ) +#' file.remove(beast2_input_file) #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_ccp_tree_prior() -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_ccp_tree_prior() +#' ) +#' file.remove(beast2_input_file) #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_cep_tree_prior() -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_cep_tree_prior() +#' ) +#' file.remove(beast2_input_file) #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = create_yule_tree_prior() -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = create_yule_tree_prior() +#' ) +#' file.remove(beast2_input_file) #' @export create_tree_prior <- function( name, @@ -100,27 +100,27 @@ create_tree_prior <- function( #' its FASTA filename using \code{\link{get_alignment_id}} #' @author Richèl J.C. Bilderbeek #' @examples -#' bd_tree_prior <- create_bd_tree_prior() +#' bd_tree_prior <- create_bd_tree_prior() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = bd_tree_prior -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = bd_tree_prior +#' ) +#' file.remove(beast2_input_file) #' -#' bd_tree_prior_exp <- create_bd_tree_prior( -#' birth_rate_distr = create_exp_distr() -#' ) +#' bd_tree_prior_exp <- create_bd_tree_prior( +#' birth_rate_distr = create_exp_distr() +#' ) #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = bd_tree_prior_exp -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = bd_tree_prior_exp +#' ) +#' file.remove(beast2_input_file) #' @aliases create_bd_tree_prior create_tree_prior_bd #' @export create_bd_tree_prior create_tree_prior_bd create_bd_tree_prior <- create_tree_prior_bd <- function( @@ -143,15 +143,15 @@ create_bd_tree_prior <- create_tree_prior_bd <- function( #' its FASTA filename using \code{\link{get_alignment_id}} #' @author Richèl J.C. Bilderbeek #' @examples -#' cbs_tree_prior <- create_cbs_tree_prior() +#' cbs_tree_prior <- create_cbs_tree_prior() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_beautier_path("test_output_6.fas"), -#' beast2_input_file, -#' tree_prior = cbs_tree_prior -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_beautier_path("test_output_6.fas"), +#' beast2_input_file, +#' tree_prior = cbs_tree_prior +#' ) +#' file.remove(beast2_input_file) #' @aliases create_cbs_tree_prior create_tree_prior_cbs #' @export create_cbs_tree_prior create_tree_prior_cbs create_cbs_tree_prior <- create_tree_prior_cbs <- function( @@ -176,15 +176,15 @@ create_cbs_tree_prior <- create_tree_prior_cbs <- function( #' its FASTA filename using \code{\link{get_alignment_id}} #' @author Richèl J.C. Bilderbeek #' @examples -#' ccp_tree_prior <- create_ccp_tree_prior() +#' ccp_tree_prior <- create_ccp_tree_prior() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = ccp_tree_prior -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = ccp_tree_prior +#' ) +#' file.remove(beast2_input_file) #' @aliases create_ccp_tree_prior create_tree_prior_ccp #' @export create_ccp_tree_prior create_tree_prior_ccp create_ccp_tree_prior <- create_tree_prior_ccp <- function( @@ -211,15 +211,15 @@ create_ccp_tree_prior <- create_tree_prior_ccp <- function( #' its FASTA filename using \code{\link{get_alignment_id}} #' @author Richèl J.C. Bilderbeek #' @examples -#' cep_tree_prior <- create_cep_tree_prior() +#' cep_tree_prior <- create_cep_tree_prior() #' -#' beast2_input_file <- tempfile(fileext = ".xml") -#' create_beast2_input_file( -#' input_filename = get_fasta_filename(), -#' beast2_input_file, -#' tree_prior = cep_tree_prior -#' ) -#' testit::assert(file.exists(beast2_input_file)) +#' beast2_input_file <- get_beautier_tempfilename() +#' create_beast2_input_file( +#' input_filename = get_fasta_filename(), +#' beast2_input_file, +#' tree_prior = cep_tree_prior +#' ) +#' file.remove(beast2_input_file) #' @aliases create_cep_tree_prior create_tree_prior_cep #' @export create_cep_tree_prior create_tree_prior_cep create_cep_tree_prior <- create_tree_prior_cep <- function( @@ -251,12 +251,13 @@ create_cep_tree_prior <- create_tree_prior_cep <- function( #' @examples #' yule_tree_prior <- create_yule_tree_prior() #' -#' beast2_input_file <- tempfile(fileext = ".xml") +#' beast2_input_file <- get_beautier_tempfilename() #' create_beast2_input_file( #' input_filename = get_fasta_filename(), #' beast2_input_file, #' tree_prior = yule_tree_prior #' ) +#' file.remove(beast2_input_file) #' @aliases create_yule_tree_prior create_tree_prior_yule #' @export create_yule_tree_prior create_tree_prior_yule create_yule_tree_prior <- create_tree_prior_yule <- function( diff --git a/R/get_beautier_tempfilename.R b/R/get_beautier_tempfilename.R index 2e31f23d..52201c10 100644 --- a/R/get_beautier_tempfilename.R +++ b/R/get_beautier_tempfilename.R @@ -1,11 +1,14 @@ #' Get a temporary filename #' -#' Get a temporary filename, similar to \linky{tempfile}, +#' Get a temporary filename, similar to \link{tempfile}, #' except that it always writes to a temporary folder #' named \link{beautier}. #' @note this function is added to make sure no temporary #' cache files are left undeleted -#' @inheritParams tempfile +#' @param pattern a non-empty character vector +#' giving the initial part of the name. +#' @param fileext a non-empty character vector +#' giving the file extension #' @return name for a temporary file #' @export get_beautier_tempfilename <- function( diff --git a/R/get_remove_hex_fun.R b/R/get_remove_hex_fun.R index 529d3df3..2da66b8f 100644 --- a/R/get_remove_hex_fun.R +++ b/R/get_remove_hex_fun.R @@ -5,7 +5,8 @@ #' where \code{/home/john/.cache} is the location to a temporary folder #' (on Linux) and \code{tracelog_82c5888db98.log} the filename. #' The filename ends with a hex string (as is common for temporary files, -#' as \link{tempfile} does so). Because \link{beautier} puts an underscore +#' as \link{tempfile} does so). +#' Because \link{beautier} puts an underscore #' between the filename description (\code{tracelog}) and the hex #' string, this function removes both. #' diff --git a/R/get_test_filenames.R b/R/get_test_filenames.R index 07f4b002..b2363aa6 100644 --- a/R/get_test_filenames.R +++ b/R/get_test_filenames.R @@ -1,13 +1,15 @@ #' Get the path of a FASTA file used in testing #' @return the path of a FASTA file used in testing #' @examples -#' filename <- beautier::get_fasta_filename() -#' testit::assert(file.exists(filename)) +#' input_filename <- beautier::get_fasta_filename() +#' output_filename <- get_beautier_tempfilename() #' -#' create_beast2_input_file( -#' input_filename = filename, -#' output_filename = tempfile(pattern = "beast", fileext = ".xml") -#' ) +#' create_beast2_input_file( +#' input_filename = input_filename, +#' output_filename = output_filename +#' ) +#' +#' file.remove(output_filename) #' @author Richèl J.C. Bilderbeek #' @export get_fasta_filename <- function() { diff --git a/doc/demo.R b/doc/demo.R index c9d01c05..dfb75d40 100644 --- a/doc/demo.R +++ b/doc/demo.R @@ -14,7 +14,7 @@ fasta_filename <- get_beautier_path("test_output_0.fas") image(ape::read.FASTA(fasta_filename)) ## ----create_output_filename--------------------------------------------------- -output_filename <- tempfile(pattern = "beast2", fileext = ".xml") +output_filename <- get_beautier_tempfilename(pattern = "beast2", fileext = ".xml") output_filename ## ----create_beast2_input_file------------------------------------------------- diff --git a/man/beautier.Rd b/man/beautier.Rd index 674ed8f3..df0169de 100644 --- a/man/beautier.Rd +++ b/man/beautier.Rd @@ -19,7 +19,7 @@ features of BEAST2 that \code{beautier} supports. input_filename <- get_fasta_filename() # The file created by beautier, a BEAST2 input file -output_filename <- tempfile() +output_filename <- get_beautier_tempfilename() # Use the default BEAUti settings to create a BEAST2 input file create_beast2_input_file_from_model( @@ -27,6 +27,7 @@ create_beast2_input_file_from_model( output_filename, inference_model = create_inference_model() ) +file.remove(output_filename) } \seealso{ These are packages associated with \code{beautier}: diff --git a/man/create_alpha_param.Rd b/man/create_alpha_param.Rd index f3d9b933..da00c66e 100644 --- a/man/create_alpha_param.Rd +++ b/man/create_alpha_param.Rd @@ -28,24 +28,24 @@ and inverse-gamma distribution It cannot be estimated (as a hyper parameter) yet. } \examples{ - # Create the parameter - alpha_param <- create_alpha_param() +# Create the parameter +alpha_param <- create_alpha_param() - # Use the parameter in a distribution - beta_distr <- create_beta_distr( - alpha = alpha_param - ) +# Use the parameter in a distribution +beta_distr <- create_beta_distr( + alpha = alpha_param +) - # Use the distribution to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = beta_distr - ) +# Use the distribution to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = beta_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_bd_tree_prior.Rd b/man/create_bd_tree_prior.Rd index 3a91c475..4a396019 100644 --- a/man/create_bd_tree_prior.Rd +++ b/man/create_bd_tree_prior.Rd @@ -27,27 +27,27 @@ a Birth-Death tree_prior Create a Birth-Death tree prior } \examples{ - bd_tree_prior <- create_bd_tree_prior() +bd_tree_prior <- create_bd_tree_prior() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = bd_tree_prior - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = bd_tree_prior +) +file.remove(beast2_input_file) - bd_tree_prior_exp <- create_bd_tree_prior( - birth_rate_distr = create_exp_distr() - ) +bd_tree_prior_exp <- create_bd_tree_prior( + birth_rate_distr = create_exp_distr() +) - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = bd_tree_prior_exp - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = bd_tree_prior_exp +) +file.remove(beast2_input_file) } \seealso{ An alignment ID can be extracted from diff --git a/man/create_beast2_input_file.Rd b/man/create_beast2_input_file.Rd index 11902472..7cd54ad1 100644 --- a/man/create_beast2_input_file.Rd +++ b/man/create_beast2_input_file.Rd @@ -84,12 +84,13 @@ Create a BEAST2 input file input_filename <- get_fasta_filename() # The file created by beautier, a BEAST2 input file -output_filename <- tempfile(pattern = "beast2", fileext = ".xml") +output_filename <- get_beautier_tempfilename() create_beast2_input_file( input_filename, output_filename ) +file.remove(output_filename) } \seealso{ Use \link{create_beast2_input_file_from_model} to do the same with an diff --git a/man/create_beast2_input_file_from_model.Rd b/man/create_beast2_input_file_from_model.Rd index f492b568..14605cc8 100644 --- a/man/create_beast2_input_file_from_model.Rd +++ b/man/create_beast2_input_file_from_model.Rd @@ -32,11 +32,13 @@ nothing Create a BEAST2 input file from an inference model } \examples{ +output_filename <- get_beautier_tempfilename() create_beast2_input_file_from_model( input_filename = get_fasta_filename(), - output_filename = tempfile(), + output_filename = output_filename, inference_model = create_inference_model() ) +file.remove(output_filename) } \seealso{ use \link{create_beast2_input_from_model} to diff --git a/man/create_beta_distr.Rd b/man/create_beta_distr.Rd index 0cbf26dc..9dffca2d 100644 --- a/man/create_beta_distr.Rd +++ b/man/create_beta_distr.Rd @@ -45,17 +45,17 @@ a beta distribution Create a beta distribution } \examples{ - beta_distr <- create_beta_distr() +beta_distr <- create_beta_distr() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = beta_distr - ) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = beta_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_distr}} shows an overview diff --git a/man/create_beta_param.Rd b/man/create_beta_param.Rd index f2190791..bbabaf2c 100644 --- a/man/create_beta_param.Rd +++ b/man/create_beta_param.Rd @@ -28,24 +28,24 @@ and inverse-gamma distribution It cannot be estimated (as a hyper parameter) yet. } \examples{ - # Create the parameter - beta_param <- create_beta_param() +# Create the parameter +beta_param <- create_beta_param() - # Use the parameter in a distribution - gamma_distr <- create_gamma_distr( - beta = beta_param - ) +# Use the parameter in a distribution +gamma_distr <- create_gamma_distr( + beta = beta_param +) - # Use the distribution to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = gamma_distr - ) +# Use the distribution to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = gamma_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_cbs_tree_prior.Rd b/man/create_cbs_tree_prior.Rd index 177021c0..002a6e14 100644 --- a/man/create_cbs_tree_prior.Rd +++ b/man/create_cbs_tree_prior.Rd @@ -22,15 +22,15 @@ a Coalescent Bayesian Skyline tree_prior Create a Coalescent Bayesian Skyline tree prior } \examples{ - cbs_tree_prior <- create_cbs_tree_prior() +cbs_tree_prior <- create_cbs_tree_prior() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_beautier_path("test_output_6.fas"), - beast2_input_file, - tree_prior = cbs_tree_prior - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_beautier_path("test_output_6.fas"), + beast2_input_file, + tree_prior = cbs_tree_prior +) +file.remove(beast2_input_file) } \seealso{ An alignment ID can be extracted from diff --git a/man/create_ccp_tree_prior.Rd b/man/create_ccp_tree_prior.Rd index c25fb8c8..ae46506a 100644 --- a/man/create_ccp_tree_prior.Rd +++ b/man/create_ccp_tree_prior.Rd @@ -23,15 +23,15 @@ a Coalescent Constant Population tree_prior Create a Coalescent Constant Population tree prior } \examples{ - ccp_tree_prior <- create_ccp_tree_prior() +ccp_tree_prior <- create_ccp_tree_prior() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = ccp_tree_prior - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = ccp_tree_prior +) +file.remove(beast2_input_file) } \seealso{ An alignment ID can be extracted from diff --git a/man/create_cep_tree_prior.Rd b/man/create_cep_tree_prior.Rd index 316df2ae..c8dd4247 100644 --- a/man/create_cep_tree_prior.Rd +++ b/man/create_cep_tree_prior.Rd @@ -27,15 +27,15 @@ a Coalescent Exponential Population tree_prior Create a Coalescent Exponential Population tree prior } \examples{ - cep_tree_prior <- create_cep_tree_prior() +cep_tree_prior <- create_cep_tree_prior() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = cep_tree_prior - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = cep_tree_prior +) +file.remove(beast2_input_file) } \seealso{ An alignment ID can be extracted from diff --git a/man/create_clock_model.Rd b/man/create_clock_model.Rd index 27d2c8f3..65c05bd0 100644 --- a/man/create_clock_model.Rd +++ b/man/create_clock_model.Rd @@ -26,25 +26,25 @@ Prefer using the named function and \code{\link{create_strict_clock_model}} } \examples{ - rln_clock_model <- create_rln_clock_model() +rln_clock_model <- create_rln_clock_model() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - get_fasta_filename(), - beast2_input_file, - clock_model = rln_clock_model - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + get_fasta_filename(), + beast2_input_file, + clock_model = rln_clock_model +) +file.remove(beast2_input_file) - strict_clock_model <- create_strict_clock_model() +strict_clock_model <- create_strict_clock_model() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - get_fasta_filename(), - beast2_input_file, - clock_model = strict_clock_model - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + get_fasta_filename(), + beast2_input_file, + clock_model = strict_clock_model +) +file.remove(beast2_input_file) } \seealso{ An alignment ID can be extracted from diff --git a/man/create_clock_rate_param.Rd b/man/create_clock_rate_param.Rd index 720870ab..af3c64a9 100644 --- a/man/create_clock_rate_param.Rd +++ b/man/create_clock_rate_param.Rd @@ -24,23 +24,23 @@ Create a parameter called \code{clock_rate}, It cannot be estimated (as a hyper parameter) yet. } \examples{ - clock_rate_param <- create_clock_rate_param( - id = "anthus_aco", value = 1.0 - ) +clock_rate_param <- create_clock_rate_param( + id = "anthus_aco", value = 1.0 +) - # Use the parameter in a clock model - strict_clock_model <- create_strict_clock_model( - clock_rate_param = clock_rate_param - ) +# Use the parameter in a clock model +strict_clock_model <- create_strict_clock_model( + clock_rate_param = clock_rate_param +) - # Use the distribution to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - clock_model = strict_clock_model - ) - testit::assert(file.exists(beast2_input_file)) +# Use the distribution to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + clock_model = strict_clock_model +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_distr.Rd b/man/create_distr.Rd index 5c1baba0..ff04c813 100644 --- a/man/create_distr.Rd +++ b/man/create_distr.Rd @@ -55,18 +55,18 @@ See for examples how to use those distributions } \examples{ - # Use any distribution - distr <- create_beta_distr() +# Use any distribution +distr <- create_beta_distr() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = distr - ) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \author{ Richèl J.C. Bilderbeek diff --git a/man/create_exp_distr.Rd b/man/create_exp_distr.Rd index 46358243..555215b9 100644 --- a/man/create_exp_distr.Rd +++ b/man/create_exp_distr.Rd @@ -29,17 +29,17 @@ an exponential distribution Create an exponential distribution } \examples{ - exp_distr <- create_exp_distr() +exp_distr <- create_exp_distr() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = exp_distr - ) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = exp_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_distr}} shows an overview diff --git a/man/create_gamma_distr.Rd b/man/create_gamma_distr.Rd index fb56a5d4..bc97dd83 100644 --- a/man/create_gamma_distr.Rd +++ b/man/create_gamma_distr.Rd @@ -41,22 +41,22 @@ a gamma distribution Create a gamma distribution } \examples{ - gamma_distr <- create_gamma_distr( - alpha = 0.05, - beta = 10.0 - ) +gamma_distr <- create_gamma_distr( + alpha = 0.05, + beta = 10.0 +) - gtr_site_model <- create_gtr_site_model( - rate_ac_prior_distr = gamma_distr - ) +gtr_site_model <- create_gtr_site_model( + rate_ac_prior_distr = gamma_distr +) - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - site_model = gtr_site_model - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + site_model = gtr_site_model +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_distr}} shows an overview diff --git a/man/create_gamma_site_model.Rd b/man/create_gamma_site_model.Rd index 71591069..001e0302 100644 --- a/man/create_gamma_site_model.Rd +++ b/man/create_gamma_site_model.Rd @@ -42,17 +42,17 @@ a gamma site model Create a gamma site model, part of a site model } \examples{ - gamma_site_model <- create_gamma_site_model(prop_invariant = 0.5) +gamma_site_model <- create_gamma_site_model(prop_invariant = 0.5) - site_model <- create_hky_site_model(gamma_site_model = gamma_site_model) +site_model <- create_hky_site_model(gamma_site_model = gamma_site_model) - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - get_fasta_filename(), - beast2_input_file, - site_model = site_model - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + get_fasta_filename(), + beast2_input_file, + site_model = site_model +) +file.remove(beast2_input_file) } \seealso{ Use \code{\link{create_gamma_site_model}} diff --git a/man/create_gtr_site_model.Rd b/man/create_gtr_site_model.Rd index ffa8371c..5104f3fa 100644 --- a/man/create_gtr_site_model.Rd +++ b/man/create_gtr_site_model.Rd @@ -91,22 +91,22 @@ a GTR site_model Create a GTR site model } \examples{ - gtr_site_model <- create_gtr_site_model( - rate_ac_param = 1.2, - rate_ag_param = 2.3, - rate_at_param = 3.4, - rate_cg_param = 4.5, - rate_ct_param = 5.6, - rate_gt_param = 6.7 - ) +gtr_site_model <- create_gtr_site_model( + rate_ac_param = 1.2, + rate_ag_param = 2.3, + rate_at_param = 3.4, + rate_cg_param = 4.5, + rate_ct_param = 5.6, + rate_gt_param = 6.7 +) - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - site_model = gtr_site_model - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + site_model = gtr_site_model +) +file.remove(beast2_input_file) } \author{ Richèl J.C. Bilderbeek diff --git a/man/create_hky_site_model.Rd b/man/create_hky_site_model.Rd index 58ce8742..1cdd86d9 100644 --- a/man/create_hky_site_model.Rd +++ b/man/create_hky_site_model.Rd @@ -41,12 +41,13 @@ Create an HKY site model } \examples{ hky_site_model <- create_hky_site_model() - + output_filename <- get_beautier_tempfilename() create_beast2_input_file( input_filename = get_fasta_filename(), - output_filename = tempfile(pattern = "beast", fileext = ".xml"), + output_filename = output_filename, site_model = hky_site_model ) +file.remove(output_filename) } \author{ Richèl J.C. Bilderbeek diff --git a/man/create_inference_model.Rd b/man/create_inference_model.Rd index 0c3449af..ea0bed7b 100644 --- a/man/create_inference_model.Rd +++ b/man/create_inference_model.Rd @@ -55,11 +55,13 @@ inference_model <- create_inference_model( mcmc = create_mcmc(chain_length = 50000, store_every = 1000) ) +output_filename <- get_beautier_tempfilename() create_beast2_input_file_from_model( input_filename = get_fasta_filename(), - output_filename = tempfile(fileext = ".xml"), + output_filename = output_filename, inference_model = inference_model ) +file.remove(beast2_input_file) } \seealso{ Use \link{create_test_inference_model} to create an inference model diff --git a/man/create_inv_gamma_distr.Rd b/man/create_inv_gamma_distr.Rd index ef23af9c..a875fb59 100644 --- a/man/create_inv_gamma_distr.Rd +++ b/man/create_inv_gamma_distr.Rd @@ -41,17 +41,17 @@ an inverse-gamma distribution Create an inverse-gamma distribution } \examples{ - inv_gamma_distr <- create_inv_gamma_distr() +inv_gamma_distr <- create_inv_gamma_distr() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = inv_gamma_distr - ) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = inv_gamma_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_distr}} shows an overview diff --git a/man/create_jc69_site_model.Rd b/man/create_jc69_site_model.Rd index dffd3ed7..f19e7c78 100644 --- a/man/create_jc69_site_model.Rd +++ b/man/create_jc69_site_model.Rd @@ -23,11 +23,13 @@ Create a JC69 site model \examples{ jc69_site_model <- create_jc69_site_model() + output_filename <- get_beautier_tempfilename() create_beast2_input_file( input_filename = get_fasta_filename(), - output_filename = tempfile(pattern = "beast", fileext = ".xml"), + output_filename = output_filename, site_model = jc69_site_model ) +file.remove(output_filename) } \author{ Richèl J.C. Bilderbeek diff --git a/man/create_lambda_param.Rd b/man/create_lambda_param.Rd index bf7eab75..bcd83ba5 100644 --- a/man/create_lambda_param.Rd +++ b/man/create_lambda_param.Rd @@ -23,24 +23,24 @@ this parameter is used in a Poisson distribution (as returned by \code{\link{create_poisson_distr}}) } \examples{ - # Create the parameter - lambda_param <- create_lambda_param() +# Create the parameter +lambda_param <- create_lambda_param() - # Use the parameter in a distribution - poisson_distr <- create_poisson_distr( - lambda = lambda_param - ) +# Use the parameter in a distribution +poisson_distr <- create_poisson_distr( + lambda = lambda_param +) - # Use the distribution to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = poisson_distr - ) +# Use the distribution to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = poisson_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_laplace_distr.Rd b/man/create_laplace_distr.Rd index 66346338..bc835323 100644 --- a/man/create_laplace_distr.Rd +++ b/man/create_laplace_distr.Rd @@ -41,17 +41,17 @@ a Laplace distribution Create a Laplace distribution } \examples{ - laplace_distr <- create_laplace_distr() +laplace_distr <- create_laplace_distr() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = laplace_distr - ) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = laplace_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_distr}} shows an overview diff --git a/man/create_log_normal_distr.Rd b/man/create_log_normal_distr.Rd index dab26e73..355a38c6 100644 --- a/man/create_log_normal_distr.Rd +++ b/man/create_log_normal_distr.Rd @@ -41,17 +41,17 @@ a log-normal distribution Create a log-normal distribution } \examples{ - log_normal_distr <- create_log_normal_distr() +log_normal_distr <- create_log_normal_distr() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = log_normal_distr - ) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = log_normal_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_distr}} shows an overview diff --git a/man/create_m_param.Rd b/man/create_m_param.Rd index 612c8357..eecd484e 100644 --- a/man/create_m_param.Rd +++ b/man/create_m_param.Rd @@ -24,24 +24,24 @@ this parameter is used in a log-normal distribution It cannot be estimated (as a hyper parameter) yet. } \examples{ - # Create the parameter - m_param <- create_m_param() +# Create the parameter +m_param <- create_m_param() - # Use the parameter in a distribution - log_normal_distr <- create_log_normal_distr( - m = m_param - ) +# Use the parameter in a distribution +log_normal_distr <- create_log_normal_distr( + m = m_param +) - # Use the distribution to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = log_normal_distr - ) +# Use the distribution to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = log_normal_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_mcmc.Rd b/man/create_mcmc.Rd index fd35b60c..bbf07c49 100644 --- a/man/create_mcmc.Rd +++ b/man/create_mcmc.Rd @@ -59,16 +59,16 @@ There are four things that can be saved: how to specify the filename } \examples{ - # Create an MCMC chain with 50 states mcmc <- create_mcmc(chain_length = 50000, store_every = 1000) -beast2_input_file <- tempfile() +beast2_input_file <- get_beautier_tempfilename() create_beast2_input_file( get_fasta_filename(), beast2_input_file, mcmc = mcmc ) +file.remove(beast2_input_file) } \seealso{ Use \code{\link{create_test_mcmc}} to create a short regular MCMC, diff --git a/man/create_mean_param.Rd b/man/create_mean_param.Rd index 4d8fdde3..d5b3a205 100644 --- a/man/create_mean_param.Rd +++ b/man/create_mean_param.Rd @@ -26,24 +26,24 @@ this parameter is used in an exponential distribution It cannot be estimated (as a hyper parameter) yet. } \examples{ - # Create the parameter - mean_param <- create_mean_param(value = 1.0) +# Create the parameter +mean_param <- create_mean_param(value = 1.0) - # Use the parameter in a distribution - exp_distr <- create_exp_distr( - mean = mean_param - ) +# Use the parameter in a distribution +exp_distr <- create_exp_distr( + mean = mean_param +) - # Use the distribution to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = exp_distr - ) +# Use the distribution to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = exp_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_mu_param.Rd b/man/create_mu_param.Rd index 81507dd0..4c50c159 100644 --- a/man/create_mu_param.Rd +++ b/man/create_mu_param.Rd @@ -24,24 +24,24 @@ this parameter is used in a Laplace distribution It cannot be estimated (as a hyper parameter) yet. } \examples{ - # Create the parameter - mu_param <- create_mu_param() +# Create the parameter +mu_param <- create_mu_param() - # Use the parameter in a distribution - laplace_distr <- create_laplace_distr( - mu = mu_param - ) +# Use the parameter in a distribution +laplace_distr <- create_laplace_distr( + mu = mu_param +) - # Use the distribution to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = laplace_distr - ) +# Use the distribution to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = laplace_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_normal_distr.Rd b/man/create_normal_distr.Rd index 157b14ce..07a2e84b 100644 --- a/man/create_normal_distr.Rd +++ b/man/create_normal_distr.Rd @@ -41,17 +41,17 @@ a normal distribution Create an normal distribution } \examples{ - normal_distr <- create_normal_distr() +normal_distr <- create_normal_distr() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = normal_distr - ) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = normal_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_distr}} shows an overview diff --git a/man/create_ns_mcmc.Rd b/man/create_ns_mcmc.Rd index 1e7241f8..52fa52fa 100644 --- a/man/create_ns_mcmc.Rd +++ b/man/create_ns_mcmc.Rd @@ -56,21 +56,21 @@ In this context, \code{chain_length} is only an upper bound to the length of that run. } \examples{ - mcmc <- create_ns_mcmc( - chain_length = 1e7, - store_every = 1000, - particle_count = 1, - sub_chain_length = 1000, - epsilon = 1e-12 - ) +mcmc <- create_ns_mcmc( + chain_length = 1e7, + store_every = 1000, + particle_count = 1, + sub_chain_length = 1000, + epsilon = 1e-12 +) - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - get_fasta_filename(), - beast2_input_file, - mcmc = mcmc - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + get_fasta_filename(), + beast2_input_file, + mcmc = mcmc +) +file.remove(beast2_input_file) } \references{ * [1] Patricio Maturana Russel, Brendon J Brewer, Steffen Klaere, diff --git a/man/create_one_div_x_distr.Rd b/man/create_one_div_x_distr.Rd index f5592c98..f75ba5fc 100644 --- a/man/create_one_div_x_distr.Rd +++ b/man/create_one_div_x_distr.Rd @@ -24,17 +24,17 @@ a 1/x distribution Create a 1/x distribution } \examples{ - one_div_x_distr <- create_one_div_x_distr() +one_div_x_distr <- create_one_div_x_distr() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = one_div_x_distr - ) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = one_div_x_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_distr}} shows an overview diff --git a/man/create_param.Rd b/man/create_param.Rd index fc6b46a7..6be11d75 100644 --- a/man/create_param.Rd +++ b/man/create_param.Rd @@ -45,24 +45,24 @@ Prefer using the and \code{\link{create_sigma_param}} } \examples{ - # Create an alpha parameter - alpha_param <- create_alpha_param() +# Create an alpha parameter +alpha_param <- create_alpha_param() - # Use the parameter in a distribution - beta_distr <- create_beta_distr( - alpha = alpha_param - ) +# Use the parameter in a distribution +beta_distr <- create_beta_distr( + alpha = alpha_param +) - # Use the distribution to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = beta_distr - ) +# Use the distribution to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = beta_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \author{ Richèl J.C. Bilderbeek diff --git a/man/create_poisson_distr.Rd b/man/create_poisson_distr.Rd index a62df7a0..94756231 100644 --- a/man/create_poisson_distr.Rd +++ b/man/create_poisson_distr.Rd @@ -29,17 +29,17 @@ a Poisson distribution Create a Poisson distribution } \examples{ - poisson_distr <- create_poisson_distr() +poisson_distr <- create_poisson_distr() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = poisson_distr - ) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = poisson_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_distr}} shows an overview diff --git a/man/create_rate_ac_param.Rd b/man/create_rate_ac_param.Rd index 008ce57e..0c2043e2 100644 --- a/man/create_rate_ac_param.Rd +++ b/man/create_rate_ac_param.Rd @@ -25,19 +25,19 @@ a parameter called 'rate AC' Create a parameter called 'rate AC' } \examples{ - # Create parameter - rate_ac_param <- create_rate_ac_param(value = 1, estimate = FALSE) +# Create parameter +rate_ac_param <- create_rate_ac_param(value = 1, estimate = FALSE) - # Use the parameter to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - site_model = create_gtr_site_model( - rate_ac_param = rate_ac_param - ) +# Use the parameter to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + site_model = create_gtr_site_model( + rate_ac_param = rate_ac_param ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_rate_ag_param.Rd b/man/create_rate_ag_param.Rd index 60fe5e79..46d95f91 100644 --- a/man/create_rate_ag_param.Rd +++ b/man/create_rate_ag_param.Rd @@ -25,19 +25,19 @@ a parameter called 'rate AG' Create a parameter called 'rate AG' } \examples{ - # Create parameter - rate_ag_param <- create_rate_ag_param(value = 1, estimate = FALSE) +# Create parameter +rate_ag_param <- create_rate_ag_param(value = 1, estimate = FALSE) - # Use the parameter to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - site_model = create_gtr_site_model( - rate_ag_param = rate_ag_param - ) +# Use the parameter to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + site_model = create_gtr_site_model( + rate_ag_param = rate_ag_param ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_rate_at_param.Rd b/man/create_rate_at_param.Rd index 98d1b2e0..84628c6e 100644 --- a/man/create_rate_at_param.Rd +++ b/man/create_rate_at_param.Rd @@ -25,19 +25,19 @@ a parameter called 'rate AT' Create a parameter called 'rate AT' } \examples{ - # Create parameter - rate_at_param <- create_rate_at_param(value = 1, estimate = FALSE) +# Create parameter +rate_at_param <- create_rate_at_param(value = 1, estimate = FALSE) - # Use the parameter to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - site_model = create_gtr_site_model( - rate_at_param = rate_at_param - ) +# Use the parameter to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + site_model = create_gtr_site_model( + rate_at_param = rate_at_param ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_rate_cg_param.Rd b/man/create_rate_cg_param.Rd index e29f1f28..de95d1de 100644 --- a/man/create_rate_cg_param.Rd +++ b/man/create_rate_cg_param.Rd @@ -25,19 +25,19 @@ a parameter called 'rate CG' Create a parameter called 'rate CG' } \examples{ - # Create parameter - rate_cg_param <- create_rate_cg_param(value = 1, estimate = FALSE) +# Create parameter +rate_cg_param <- create_rate_cg_param(value = 1, estimate = FALSE) - # Use the parameter to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - site_model = create_gtr_site_model( - rate_cg_param = rate_cg_param - ) +# Use the parameter to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + site_model = create_gtr_site_model( + rate_cg_param = rate_cg_param ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_rate_ct_param.Rd b/man/create_rate_ct_param.Rd index 69e4dc6a..2215881f 100644 --- a/man/create_rate_ct_param.Rd +++ b/man/create_rate_ct_param.Rd @@ -22,19 +22,19 @@ a parameter called 'rate CT' Create a parameter called 'rate CT' } \examples{ - # Create parameter - rate_ct_param <- create_rate_ct_param(value = 1) +# Create parameter +rate_ct_param <- create_rate_ct_param(value = 1) - # Use the parameter to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - site_model = create_gtr_site_model( - rate_ct_param = rate_ct_param - ) +# Use the parameter to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + site_model = create_gtr_site_model( + rate_ct_param = rate_ct_param ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_rate_gt_param.Rd b/man/create_rate_gt_param.Rd index e9066c6b..06abec7d 100644 --- a/man/create_rate_gt_param.Rd +++ b/man/create_rate_gt_param.Rd @@ -25,19 +25,19 @@ a parameter called 'rate GT' Create a parameter called 'rate GT' } \examples{ - # Create parameter - rate_gt_param <- create_rate_gt_param(value = 1, estimate = FALSE) +# Create parameter +rate_gt_param <- create_rate_gt_param(value = 1, estimate = FALSE) - # Use the parameter to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - site_model = create_gtr_site_model( - rate_gt_param = rate_gt_param - ) +# Use the parameter to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + site_model = create_gtr_site_model( + rate_gt_param = rate_gt_param ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_rln_clock_model.Rd b/man/create_rln_clock_model.Rd index cabe99e8..2da206d5 100644 --- a/man/create_rln_clock_model.Rd +++ b/man/create_rln_clock_model.Rd @@ -52,27 +52,27 @@ a relaxed log-normal clock_model Create a relaxed log-normal clock model } \examples{ - rln_clock_model <- create_rln_clock_model() +rln_clock_model <- create_rln_clock_model() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - get_fasta_filename(), - beast2_input_file, - clock_model = rln_clock_model - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + get_fasta_filename(), + beast2_input_file, + clock_model = rln_clock_model +) +file.remove(beast2_input_file) - rln_clock_model_exp <- create_rln_clock_model( - mean_rate_prior_distr = create_exp_distr() - ) +rln_clock_model_exp <- create_rln_clock_model( + mean_rate_prior_distr = create_exp_distr() +) - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - get_fasta_filename(), - beast2_input_file, - clock_model = rln_clock_model_exp - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + get_fasta_filename(), + beast2_input_file, + clock_model = rln_clock_model_exp +) +file.remove(beast2_input_file) } \author{ Richèl J.C. Bilderbeek diff --git a/man/create_s_param.Rd b/man/create_s_param.Rd index 236c89e1..b5abc0d9 100644 --- a/man/create_s_param.Rd +++ b/man/create_s_param.Rd @@ -28,24 +28,24 @@ this parameter is used in a log-normal distribution (as returned by \code{\link{create_log_normal_distr}}) } \examples{ - # Create the parameter - s_param <- create_s_param() +# Create the parameter +s_param <- create_s_param() - # Use the parameter in a distribution - log_normal_distr <- create_log_normal_distr( - s = s_param - ) +# Use the parameter in a distribution +log_normal_distr <- create_log_normal_distr( + s = s_param +) - # Use the distribution to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = log_normal_distr - ) +# Use the distribution to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = log_normal_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_scale_param.Rd b/man/create_scale_param.Rd index 343950db..86362cac 100644 --- a/man/create_scale_param.Rd +++ b/man/create_scale_param.Rd @@ -23,24 +23,24 @@ this parameter is used in a Laplace distribution (as returned by \code{\link{create_laplace_distr}}) } \examples{ - # Create the parameter - scale_param <- create_scale_param() +# Create the parameter +scale_param <- create_scale_param() - # Use the parameter in a distribution - laplace_distr <- create_laplace_distr( - scale = scale_param - ) +# Use the parameter in a distribution +laplace_distr <- create_laplace_distr( + scale = scale_param +) - # Use the distribution to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = laplace_distr - ) +# Use the distribution to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = laplace_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_sigma_param.Rd b/man/create_sigma_param.Rd index d3cbbd75..df7fa072 100644 --- a/man/create_sigma_param.Rd +++ b/man/create_sigma_param.Rd @@ -23,24 +23,24 @@ this parameter is used in a normal distribution (as returned by \code{\link{create_normal_distr}}) } \examples{ - # Create the parameter - sigma_param <- create_sigma_param() +# Create the parameter +sigma_param <- create_sigma_param() - # Use the parameter in a distribution - normal_distr <- create_normal_distr( - sigma = sigma_param - ) +# Use the parameter in a distribution +normal_distr <- create_normal_distr( + sigma = sigma_param +) - # Use the distribution to create a BEAST2 input file - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = normal_distr - ) +# Use the distribution to create a BEAST2 input file +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = normal_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_param}} contains a list diff --git a/man/create_site_model.Rd b/man/create_site_model.Rd index 40827616..a05ea38f 100644 --- a/man/create_site_model.Rd +++ b/man/create_site_model.Rd @@ -36,36 +36,40 @@ Prefer using the input_filename <- get_fasta_filename() # GTR -output_filename <- tempfile(pattern = "example_gtr", fileext = ".xml") +output_filename <- get_beautier_tempfilename() create_beast2_input_file( input_filename = input_filename, output_filename = output_filename, site_model = create_gtr_site_model() ) +file.remove(output_filename) # HKY -output_filename <- tempfile(pattern = "example_hky", fileext = ".xml") +output_filename <- get_beautier_tempfilename() create_beast2_input_file( input_filename = input_filename, output_filename = output_filename, site_model = create_hky_site_model() ) +file.remove(output_filename) # JC69 -output_filename <- tempfile(pattern = "example_jc69", fileext = ".xml") +output_filename <- get_beautier_tempfilename() create_beast2_input_file( input_filename = input_filename, output_filename = output_filename, site_model = create_jc69_site_model() ) +file.remove(output_filename) # TN93 -output_filename <- tempfile(pattern = "example_tn93", fileext = ".xml") +output_filename <- get_beautier_tempfilename() create_beast2_input_file( input_filename = input_filename, output_filename = output_filename, site_model = create_tn93_site_model() ) +file.remove(output_filename) } \seealso{ See \code{\link{create_gtr_site_model}} for more examples diff --git a/man/create_strict_clock_model.Rd b/man/create_strict_clock_model.Rd index 474ad282..c4634f56 100644 --- a/man/create_strict_clock_model.Rd +++ b/man/create_strict_clock_model.Rd @@ -31,30 +31,30 @@ a strict clock_model Create a strict clock model } \examples{ - strict_clock_model <- create_strict_clock_model( - clock_rate_param = 1.0, - clock_rate_distr = create_uniform_distr() - ) +strict_clock_model <- create_strict_clock_model( + clock_rate_param = 1.0, + clock_rate_distr = create_uniform_distr() +) - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - get_fasta_filename(), - beast2_input_file, - clock_model = strict_clock_model - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + get_fasta_filename(), + beast2_input_file, + clock_model = strict_clock_model +) +file.remove(beast2_input_file) - strict_clock_model_gamma <- create_strict_clock_model( - clock_rate_distr = create_gamma_distr() - ) +strict_clock_model_gamma <- create_strict_clock_model( + clock_rate_distr = create_gamma_distr() +) - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - get_fasta_filename(), - beast2_input_file, - clock_model = strict_clock_model_gamma - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + get_fasta_filename(), + beast2_input_file, + clock_model = strict_clock_model_gamma +) +file.remove(beast2_input_file) } \author{ Richèl J.C. Bilderbeek diff --git a/man/create_test_inference_model.Rd b/man/create_test_inference_model.Rd index 0447d7d8..eb759b1f 100644 --- a/man/create_test_inference_model.Rd +++ b/man/create_test_inference_model.Rd @@ -52,12 +52,13 @@ to be used in testing. \examples{ inference_model <- create_test_inference_model() -beast2_input_file <- tempfile(fileext = ".xml") +beast2_input_file <- get_beautier_tempfilename() create_beast2_input_file_from_model( get_fasta_filename(), beast2_input_file, inference_model = inference_model ) +file.remove(beast2_input_file) } \seealso{ Use \link{create_inference_model} to create a diff --git a/man/create_test_mcmc.Rd b/man/create_test_mcmc.Rd index 0034b35e..3f1226a3 100644 --- a/man/create_test_mcmc.Rd +++ b/man/create_test_mcmc.Rd @@ -48,12 +48,13 @@ Create an MCMC configuration for testing. # Create an MCMC chain with 50 states mcmc <- create_test_mcmc() -beast2_input_file <- tempfile(fileext = ".xml") +beast2_input_file <- get_beautier_tempfilename() create_beast2_input_file( get_fasta_filename(), beast2_input_file, mcmc = mcmc ) +file.remove(beast2_input_file) } \seealso{ Use \code{\link{create_mcmc}} to create a default BEAST2 MCMC diff --git a/man/create_test_ns_mcmc.Rd b/man/create_test_ns_mcmc.Rd index 85a70128..146a2ca7 100644 --- a/man/create_test_ns_mcmc.Rd +++ b/man/create_test_ns_mcmc.Rd @@ -51,16 +51,14 @@ an MCMC object Create an NS MCMC object for testing } \examples{ - mcmc <- create_test_ns_mcmc() - -beast2_input_file <- tempfile(fileext = ".xml") - +beast2_input_file <- get_beautier_tempfilename() create_beast2_input_file( get_fasta_filename(), beast2_input_file, mcmc = mcmc ) +file.remove(beast2_input_file) } \seealso{ Use \code{\link{create_ns_mcmc}} to create a default diff --git a/man/create_tn93_site_model.Rd b/man/create_tn93_site_model.Rd index e3a92509..9100217c 100644 --- a/man/create_tn93_site_model.Rd +++ b/man/create_tn93_site_model.Rd @@ -59,11 +59,13 @@ Create a TN93 site model kappa_2_param = 2.0 ) + output_filename <- get_beautier_tempfilename() create_beast2_input_file( input_filename = get_fasta_filename(), - output_filename = tempfile(pattern = "beast", fileext = ".xml"), + output_filename = output_filename, site_model = tn93_site_model ) +file.remove(output_filename) } \author{ Richèl J.C. Bilderbeek diff --git a/man/create_tree_prior.Rd b/man/create_tree_prior.Rd index ac45e7b1..b977d1a3 100644 --- a/man/create_tree_prior.Rd +++ b/man/create_tree_prior.Rd @@ -30,45 +30,45 @@ Prefer the use the named functions instead } \examples{ - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_bd_tree_prior() - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_bd_tree_prior() +) +file.remove(beast2_input_file) - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_beautier_path("test_output_6.fas"), - beast2_input_file, - tree_prior = create_cbs_tree_prior() - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_beautier_path("test_output_6.fas"), + beast2_input_file, + tree_prior = create_cbs_tree_prior() +) +file.remove(beast2_input_file) - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_ccp_tree_prior() - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_ccp_tree_prior() +) +file.remove(beast2_input_file) - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_cep_tree_prior() - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_cep_tree_prior() +) +file.remove(beast2_input_file) - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior() - ) - testit::assert(file.exists(beast2_input_file)) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior() +) +file.remove(beast2_input_file) } \seealso{ See diff --git a/man/create_uniform_distr.Rd b/man/create_uniform_distr.Rd index 13b0e680..1ea27068 100644 --- a/man/create_uniform_distr.Rd +++ b/man/create_uniform_distr.Rd @@ -24,17 +24,17 @@ a uniform distribution Create a uniform distribution } \examples{ - uniform_distr <- create_uniform_distr() +uniform_distr <- create_uniform_distr() - beast2_input_file <- tempfile(fileext = ".xml") - create_beast2_input_file( - input_filename = get_fasta_filename(), - beast2_input_file, - tree_prior = create_yule_tree_prior( - birth_rate_distr = uniform_distr - ) +beast2_input_file <- get_beautier_tempfilename() +create_beast2_input_file( + input_filename = get_fasta_filename(), + beast2_input_file, + tree_prior = create_yule_tree_prior( + birth_rate_distr = uniform_distr ) - testit::assert(file.exists(beast2_input_file)) +) +file.remove(beast2_input_file) } \seealso{ the function \code{\link{create_distr}} shows an overview diff --git a/man/create_yule_tree_prior.Rd b/man/create_yule_tree_prior.Rd index c4fb8767..ba25e124 100644 --- a/man/create_yule_tree_prior.Rd +++ b/man/create_yule_tree_prior.Rd @@ -25,12 +25,13 @@ Create a Yule tree prior \examples{ yule_tree_prior <- create_yule_tree_prior() - beast2_input_file <- tempfile(fileext = ".xml") + beast2_input_file <- get_beautier_tempfilename() create_beast2_input_file( input_filename = get_fasta_filename(), beast2_input_file, tree_prior = yule_tree_prior ) +file.remove(beast2_input_file) } \seealso{ An alignment ID can be extracted from diff --git a/man/get_beautier_tempfilename.Rd b/man/get_beautier_tempfilename.Rd index 6a142006..4e258c6a 100644 --- a/man/get_beautier_tempfilename.Rd +++ b/man/get_beautier_tempfilename.Rd @@ -6,11 +6,18 @@ \usage{ get_beautier_tempfilename(pattern = "file", fileext = "") } +\arguments{ +\item{pattern}{a non-empty character vector +giving the initial part of the name.} + +\item{fileext}{a non-empty character vector +giving the file extension} +} \value{ name for a temporary file } \description{ -Get a temporary filename, similar to \linky{tempfile}, +Get a temporary filename, similar to \link{tempfile}, except that it always writes to a temporary folder named \link{beautier}. } diff --git a/man/get_fasta_filename.Rd b/man/get_fasta_filename.Rd index f28eb480..19cac7dc 100644 --- a/man/get_fasta_filename.Rd +++ b/man/get_fasta_filename.Rd @@ -13,13 +13,15 @@ the path of a FASTA file used in testing Get the path of a FASTA file used in testing } \examples{ - filename <- beautier::get_fasta_filename() - testit::assert(file.exists(filename)) +input_filename <- beautier::get_fasta_filename() +output_filename <- get_beautier_tempfilename() - create_beast2_input_file( - input_filename = filename, - output_filename = tempfile(pattern = "beast", fileext = ".xml") - ) +create_beast2_input_file( + input_filename = input_filename, + output_filename = output_filename +) + +file.remove(output_filename) } \author{ Richèl J.C. Bilderbeek diff --git a/man/get_remove_hex_fun.Rd b/man/get_remove_hex_fun.Rd index 556c6bfb..bff5572b 100644 --- a/man/get_remove_hex_fun.Rd +++ b/man/get_remove_hex_fun.Rd @@ -12,7 +12,8 @@ such as \code{/home/john/.cache/tracelog_82c5888db98.log} (on Linux), where \code{/home/john/.cache} is the location to a temporary folder (on Linux) and \code{tracelog_82c5888db98.log} the filename. The filename ends with a hex string (as is common for temporary files, -as \link{tempfile} does so). Because \link{beautier} puts an underscore +as \link{tempfile} does so). +Because \link{beautier} puts an underscore between the filename description (\code{tracelog}) and the hex string, this function removes both. } diff --git a/scripts/issue_105.R b/scripts/issue_105.R index 1e228354..27d7619e 100644 --- a/scripts/issue_105.R +++ b/scripts/issue_105.R @@ -1,9 +1,9 @@ # Test if treelog$filename really creates that file library(beautier) -tracelog_filename <- tempfile() -screenlog_filename <- tempfile() -treelog_filename <- tempfile() +tracelog_filename <- get_beautier_tempfilename() +screenlog_filename <- get_beautier_tempfilename() +treelog_filename <- get_beautier_tempfilename() testit::assert(!file.exists(tracelog_filename)) testit::assert(!file.exists(screenlog_filename)) @@ -26,7 +26,7 @@ inference_model <- beautier::create_inference_model( ) ) -beast2_input_filename <- tempfile() +beast2_input_filename <- get_beautier_tempfilename() create_beast2_input_file_from_model( input_filename = get_fasta_filename(), @@ -34,7 +34,7 @@ create_beast2_input_file_from_model( inference_model = inference_model ) -new_wd <- tempfile() +new_wd <- get_beautier_tempfilename() dir.create(new_wd, recursive = TRUE) setwd(new_wd) diff --git a/tests/testthat/test-compare_lines.R b/tests/testthat/test-compare_lines.R index 9038891c..b9f47e01 100644 --- a/tests/testthat/test-compare_lines.R +++ b/tests/testthat/test-compare_lines.R @@ -7,8 +7,8 @@ test_that("compare all", { lines = readLines(beautier::get_beautier_path("bd_2_4.xml")), expected = readLines(beautier::get_beautier_path("bd_2_4.xml")), section = NA, - created_lines_filename = tempfile(), - expected_lines_filename = tempfile() + created_lines_filename = get_beautier_tempfilename(), + expected_lines_filename = get_beautier_tempfilename() ) ) }) @@ -20,8 +20,8 @@ test_that("compare state", { lines = readLines(beautier::get_beautier_path("bd_2_4.xml")), expected = readLines(beautier::get_beautier_path("bd_2_4.xml")), section = "state", - created_lines_filename = tempfile(), - expected_lines_filename = tempfile() + created_lines_filename = get_beautier_tempfilename(), + expected_lines_filename = get_beautier_tempfilename() ) ) }) @@ -33,8 +33,8 @@ test_that("compare operators", { lines = readLines(beautier::get_beautier_path("bd_2_4.xml")), expected = readLines(beautier::get_beautier_path("bd_2_4.xml")), section = "operators", - created_lines_filename = tempfile(), - expected_lines_filename = tempfile() + created_lines_filename = get_beautier_tempfilename(), + expected_lines_filename = get_beautier_tempfilename() ) ) }) diff --git a/tests/testthat/test-create_beast2_input_file.R b/tests/testthat/test-create_beast2_input_file.R index 4a8cdfbc..542dcdd8 100644 --- a/tests/testthat/test-create_beast2_input_file.R +++ b/tests/testthat/test-create_beast2_input_file.R @@ -2,7 +2,7 @@ context("create_beast2_input_file") test_that("use", { - output_filename <- tempfile() + output_filename <- get_beautier_tempfilename() testit::assert(!file.exists(output_filename)) expect_silent( @@ -17,7 +17,7 @@ test_that("use", { test_that("abuse", { - output_filename <- tempfile() + output_filename <- get_beautier_tempfilename() # input_filenames expect_error( @@ -80,7 +80,9 @@ test_that("abuse", { expect_silent( create_beast2_input_file( input_filename = get_fasta_filename(), - output_filename = file.path(tempfile(), "1", "2", "beast2.xml") + output_filename = file.path( + get_beautier_tempfilename(), "1", "2", "beast2.xml" + ) ) ) diff --git a/tests/testthat/test-create_beast2_input_file_from_model.R b/tests/testthat/test-create_beast2_input_file_from_model.R index 30bbace3..ec7f992d 100644 --- a/tests/testthat/test-create_beast2_input_file_from_model.R +++ b/tests/testthat/test-create_beast2_input_file_from_model.R @@ -1,6 +1,6 @@ test_that("use", { - output_filename <- tempfile() + output_filename <- get_beautier_tempfilename() testit::assert(!file.exists(output_filename)) expect_silent( @@ -15,7 +15,7 @@ test_that("use", { test_that("abuse", { - output_filename <- tempfile() + output_filename <- get_beautier_tempfilename() # input_filenames expect_error(