Skip to content

Commit

Permalink
Merge pull request #68 from olivroy/cran-check
Browse files Browse the repository at this point in the history
Cran check
  • Loading branch information
richelbilderbeek committed Oct 27, 2023
2 parents 05fcd88 + 49c3f56 commit 7508525
Show file tree
Hide file tree
Showing 82 changed files with 1,169 additions and 228 deletions.
6 changes: 2 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,19 @@ RoxygenNote: 7.2.3
Imports:
ape,
beautier (>= 2.6.9),
devtools,
phangorn,
rappdirs,
readr,
rJava,
rlang (>= 1.1.0),
sessioninfo,
stringr,
tibble,
xml2
Suggests:
hunspell,
knitr,
markdown,
rmarkdown,
spelling,
testit,
testthat (>= 2.1.0),
tracerer (>= 2.2.3)
URL: https://docs.ropensci.org/beastier/ (website)
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export(run_beast2_from_options)
export(save_lines)
export(save_nexus_as_fasta)
export(uninstall_beast2)
import(rlang)
importFrom(beautier,check_rename_fun)
importFrom(beautier,create_alpha_param)
importFrom(beautier,create_bd_tree_prior)
Expand Down
18 changes: 9 additions & 9 deletions R/are_beast2_input_lines.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ are_beast2_input_lines <- function(
stop("'method' must be \"deep\" or \"fast\", value was '", method, "'")
}
if (method == "deep") {
filename <- beastier::get_beastier_tempfilename()
filename <- get_beastier_tempfilename()

Check warning on line 30 in R/are_beast2_input_lines.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/are_beast2_input_lines.R,line=30,col=17,[object_usage_linter] no visible global function definition for 'get_beastier_tempfilename'
dir.create(dirname(filename), showWarnings = FALSE, recursive = TRUE)
beastier::save_lines(filename = filename, lines = lines)
is_valid <- beastier::are_beast2_input_lines_deep(
save_lines(filename = filename, lines = lines)

Check warning on line 32 in R/are_beast2_input_lines.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/are_beast2_input_lines.R,line=32,col=5,[object_usage_linter] no visible global function definition for 'save_lines'
is_valid <- are_beast2_input_lines_deep(
lines = lines,
verbose = verbose,
beast2_path = beast2_path
)
file.remove(filename)
return(is_valid)
} else {
testit::assert(method == "fast")
check_true(method == "fast")

Check warning on line 41 in R/are_beast2_input_lines.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/are_beast2_input_lines.R,line=41,col=5,[object_usage_linter] no visible global function definition for 'check_true'
return(
beastier::are_beast2_input_lines_fast(lines) # nolint internal function
are_beast2_input_lines_fast(lines) # nolint internal function
)
}
}
Expand All @@ -67,10 +67,10 @@ are_beast2_input_lines_deep <- function(
verbose = FALSE,
beast2_path = get_default_beast2_path()

Check warning on line 68 in R/are_beast2_input_lines.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/are_beast2_input_lines.R,line=68,col=17,[object_usage_linter] no visible global function definition for 'get_default_beast2_path'
) {
filename <- beastier::create_temp_input_filename()
filename <- create_temp_input_filename()

Check warning on line 70 in R/are_beast2_input_lines.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/are_beast2_input_lines.R,line=70,col=15,[object_usage_linter] no visible global function definition for 'create_temp_input_filename'
dir.create(dirname(filename), recursive = TRUE, showWarnings = FALSE)
beastier::save_lines(filename = filename, lines = lines)
is_valid <- beastier::is_beast2_input_file(
save_lines(filename = filename, lines = lines)

Check warning on line 72 in R/are_beast2_input_lines.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/are_beast2_input_lines.R,line=72,col=3,[object_usage_linter] no visible global function definition for 'save_lines'
is_valid <- is_beast2_input_file(

Check warning on line 73 in R/are_beast2_input_lines.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/are_beast2_input_lines.R,line=73,col=15,[object_usage_linter] no visible global function definition for 'is_beast2_input_file'
filename = filename,
verbose = verbose,
beast2_path = beast2_path
Expand All @@ -97,5 +97,5 @@ are_beast2_input_lines_deep <- function(
are_beast2_input_lines_fast <- function(
lines
) {
beastier::has_unique_ids(lines)
has_unique_ids(lines)

Check warning on line 100 in R/are_beast2_input_lines.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/are_beast2_input_lines.R,line=100,col=3,[object_usage_linter] no visible global function definition for 'has_unique_ids'
}
4 changes: 2 additions & 2 deletions R/are_identical_alignments.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#' @author Richèl J.C. Bilderbeek
#' @export
are_identical_alignments <- function(p, q) {
if (!beastier::is_alignment(p)) {
if (!is_alignment(p)) {

Check warning on line 8 in R/are_identical_alignments.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/are_identical_alignments.R,line=8,col=8,[object_usage_linter] no visible global function definition for 'is_alignment'
stop("p must be an alignment")
}
if (!beastier::is_alignment(q)) {
if (!is_alignment(q)) {
stop("q must be an alignment")
}
return(identical(p, q))
Expand Down
2 changes: 1 addition & 1 deletion R/beast2_options_to_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' @author Richèl J.C. Bilderbeek
#' @export
beast2_options_to_table <- function(beast2_options) {
beastier::check_beast2_options(beast2_options)
check_beast2_options(beast2_options)
tibble::tibble(
parameter = names(beast2_options),
value = unlist(beast2_options)
Expand Down
1 change: 1 addition & 0 deletions R/beastier-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,6 @@
"_PACKAGE"

## usethis namespace: start
#' @import rlang
## usethis namespace: end
NULL
14 changes: 7 additions & 7 deletions R/beastier_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ beastier_report <- function(
message("***********")
message("OS: ", os)
message("beast2_folder: ", beast2_folder)
beast2_path <- beastier::get_default_beast2_path(
beast2_path <- get_default_beast2_path(
beast2_folder = beast2_folder
)
message("beast2_path: ", beast2_path)
Expand All @@ -33,23 +33,23 @@ beastier_report <- function(
message("**********")
message("* BEAST2 *")
message("**********")
message("Java version: ", beastier::get_java_version())
message("Java version: ", get_java_version())
message(
"Is BEAST2 installed: ",
beastier::is_beast2_installed(folder_name = beast2_folder)
is_beast2_installed(folder_name = beast2_folder)
)
if (beastier::is_beast2_installed(folder_name = beast2_folder)) {
if (is_beast2_installed(folder_name = beast2_folder)) {
message(
"BEAST2 version: ",
beastier::get_beast2_version(beast2_path = beast2_path)
get_beast2_version(beast2_path = beast2_path)
)
message(
"BEAST2 default path: ",
beastier::get_default_beast2_bin_path(beast2_folder = beast2_folder)
get_default_beast2_bin_path(beast2_folder = beast2_folder)
)
}
message("****************")
message("* session info *")
message("****************")
message(paste0(devtools::session_info(), collapse = "\n"))
message(paste0(sessioninfo::session_info(), collapse = "\n"))
}
6 changes: 3 additions & 3 deletions R/check_beast2.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#' @author Richèl J.C. Bilderbeek
#' @export
check_beast2 <- function(
beast2_path = beastier::get_default_beast2_path()
beast2_path = get_default_beast2_path()
) {
tryCatch({
beastier::is_beast2_input_file(
filename = beastier::get_beastier_path("anthus_2_4.xml"),
is_beast2_input_file(
filename = get_beastier_path("anthus_2_4.xml"),
beast2_path = beast2_path
)
}, error = function(e) {
Expand Down
16 changes: 8 additions & 8 deletions R/check_beast2_options.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
check_beast2_options <- function(
beast2_options
) {
beastier::check_beast2_options_names(beast2_options)
beastier::check_beast2_options_data_types(beast2_options)
check_beast2_options_names(beast2_options)
check_beast2_options_data_types(beast2_options)
# Do not check if the BEAST2 path already/still exist.
# It shouldn't be checked by here, only when actually running BEAST2.
# By doing so, data with beast2_options can be analysed on different computers
beastier::check_beast2_options_filenames_differ(beast2_options)
check_beast2_options_filenames_differ(beast2_options)
}

#' Check if the \code{beast2_options}, which is a list,
Expand Down Expand Up @@ -67,17 +67,17 @@ check_beast2_options_names <- function( # nolint long function name indeed, whic
check_beast2_options_data_types <- function( # nolint long function name indeed, which is fine for an internal function
beast2_options
) {
testthat::expect_true(beautier::is_one_string(beast2_options$input_filename))
testthat::expect_true(beautier::is_one_string(beast2_options$output_state_filename))
beastier::check_rng_seed(beast2_options$rng_seed)
beastier::check_n_threads(beast2_options$n_threads)
check_true(beautier::is_one_string(beast2_options$input_filename))
check_true(beautier::is_one_string(beast2_options$output_state_filename))
check_rng_seed(beast2_options$rng_seed)
check_n_threads(beast2_options$n_threads)
if (!beautier::is_one_bool(beast2_options$use_beagle)) {
stop("'use_beagle' must be one boolean")
}
if (!beautier::is_one_bool(beast2_options$overwrite)) {
stop("'overwrite' must be one boolean")
}
testthat::expect_true(beautier::is_one_string(beast2_options$beast2_path))
check_true(beautier::is_one_string(beast2_options$beast2_path))
if (!beautier::is_one_bool(beast2_options$verbose)) {
stop("'verbose' must be one boolean")
}
Expand Down
2 changes: 1 addition & 1 deletion R/check_beast2_options_do_not_overwrite_existing_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
check_beast2_options_do_not_overwrite_existing_files <- function( # nolint indeed a long function name, which is fine for internal functions
beast2_options
) {
beastier::check_beast2_options(beast2_options)
check_beast2_options(beast2_options)
if (beast2_options$overwrite) {
return(invisible(beast2_options))
}
Expand Down
2 changes: 1 addition & 1 deletion R/check_beast2_optionses.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ check_beast2_optionses <- function(
}
for (i in seq_along(beast2_optionses)) {
# Stub with too simple error message
beastier::check_beast2_options(beast2_optionses[[i]])
check_beast2_options(beast2_optionses[[i]])
}
}
2 changes: 1 addition & 1 deletion R/check_can_create_dir_for_state_output_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
check_can_create_dir_for_state_output_file <- function( # nolint indeed a long function name
beast2_options
) {
beastier::check_beast2_options(beast2_options)
check_beast2_options(beast2_options)
folder <- dirname(beast2_options$output_state_filename)

# If it exists, that folder can be created
Expand Down
4 changes: 2 additions & 2 deletions R/check_can_create_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ check_can_create_file <- function(
} else {
# Delete the file
file.remove(filename)
testthat::expect_true(
check_true(
!file.exists(filename),
info = paste0(
"Cannot delete the file already present at location ", filename
Expand Down Expand Up @@ -58,7 +58,7 @@ check_can_create_file <- function(
}


testthat::expect_true(
check_true(
!file.exists(filename),
info = paste0(
"Cannot delete the temporary file created at location ", filename
Expand Down
8 changes: 4 additions & 4 deletions R/check_can_create_screenlog_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ check_can_create_screenlog_file <- function( # nolint indeed a long function nam
beast2_options
) {
# Extract the screenlog file
testthat::expect_true(file.exists(beast2_options$input_filename))
check_true(file.exists(beast2_options$input_filename))
text <- readr::read_lines(beast2_options$input_filename, progress = FALSE)
screenlog_line <- stringr::str_subset(
string = text,
pattern = "<logger id=\"screenlog\""
)
testthat::expect_equal(length(screenlog_line), 1)
check_true(length(screenlog_line) == 1)
matches <- stringr::str_match(
string = screenlog_line,
pattern = "fileName=\\\"([:graph:]+)\\\" "
)
testthat::expect_equal(ncol(matches), 2)
check_true(ncol(matches) == 2)
screenlog_filename <- matches[1, 2]

if (is.na(screenlog_filename)) return()
Expand All @@ -32,7 +32,7 @@ check_can_create_screenlog_file <- function( # nolint indeed a long function nam
}

tryCatch(
beastier::check_can_create_file(
check_can_create_file(
filename = screenlog_filename, overwrite = FALSE
),
error = function(e) {
Expand Down
6 changes: 3 additions & 3 deletions R/check_can_create_state_output_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
check_can_create_state_output_file <- function( # nolint indeed a long function name
beast2_options
) {
beastier::check_beast2_options(beast2_options)
beastier::check_can_create_dir_for_state_output_file(beast2_options)
check_beast2_options(beast2_options)
check_can_create_dir_for_state_output_file(beast2_options)
if (file.exists(beast2_options$output_state_filename)) {
return(invisible(beast2_options))
}
Expand All @@ -24,7 +24,7 @@ check_can_create_state_output_file <- function( # nolint indeed a long function

# Use a more precise error message
tryCatch(
beastier::check_can_create_file(
check_can_create_file(
filename = beast2_options$output_state_filename,
overwrite = FALSE
),
Expand Down
6 changes: 3 additions & 3 deletions R/check_can_create_tracelog_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
check_can_create_tracelog_file <- function(
beast2_options
) {
testthat::expect_true(file.exists(beast2_options$input_filename))
tracelog_filename <- beastier::extract_tracelog_filename_from_beast2_input_file( # nolint indeed a long internal function name
check_true(file.exists(beast2_options$input_filename))
tracelog_filename <- extract_tracelog_filename_from_beast2_input_file( # nolint indeed a long internal function name
input_filename = beast2_options$input_filename
)

Expand All @@ -24,7 +24,7 @@ check_can_create_tracelog_file <- function(
}

tryCatch(
beastier::check_can_create_file(
check_can_create_file(
filename = tracelog_filename, overwrite = FALSE
),
error = function(e) {
Expand Down
6 changes: 3 additions & 3 deletions R/check_can_create_treelog_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ check_can_create_treelog_file <- function(
beast2_options
) {
# Extract the treelog file
testthat::expect_true(file.exists(beast2_options$input_filename))
treelog_filename <- beastier::extract_treelog_filename_from_beast2_input_file(
check_true(file.exists(beast2_options$input_filename))
treelog_filename <- extract_treelog_filename_from_beast2_input_file(
input_filename = beast2_options$input_filename
)

Expand All @@ -22,7 +22,7 @@ check_can_create_treelog_file <- function(
}

tryCatch(
beastier::check_can_create_file(
check_can_create_file(
filename = treelog_filename, overwrite = FALSE
),
error = function(e) {
Expand Down
4 changes: 2 additions & 2 deletions R/check_input_filename.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ check_input_filename_validity <- function(
verbose <- beast2_options$verbose

if (
!beastier::is_beast2_input_file(
!is_beast2_input_file(
filename = input_filename,
verbose = verbose,
beast2_path = beast2_path
Expand All @@ -53,7 +53,7 @@ check_input_filename_validity <- function(
stop(
"'input_filename' must be a valid BEAST2 XML file. ",
"File '", input_filename, "' is not a valid BEAST2 file. ",
beastier::is_beast2_input_file(
is_beast2_input_file(
input_filename,
verbose = verbose,
beast2_path = beast2_path
Expand Down
2 changes: 1 addition & 1 deletion R/check_rng_seed.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ check_rng_seed <- function(rng_seed) {
"Actual value: ", rng_seed
)
}
testthat::expect_true(beautier::is_one_int(rng_seed))
check_true(beautier::is_one_int(rng_seed))
if (rng_seed <= 0) {
stop(
"'rng_seed' should be one NA or one non-zero positive value.\n",
Expand Down
Loading

0 comments on commit 7508525

Please sign in to comment.