Skip to content

Commit

Permalink
better input_check function again
Browse files Browse the repository at this point in the history
LunaSare committed Mar 19, 2018
1 parent e576d2f commit 38e86e9
Showing 5 changed files with 24 additions and 42 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

export(clean_chronogram)
export(datelife_authors_tabulate)
export(datelife_query_check)
export(datelife_query_length_check)
export(datelife_result_MRCA)
export(datelife_result_check)
@@ -13,7 +14,6 @@ export(get_datelife_result)
export(get_mrbayes_node_calibrations)
export(get_otol_chronograms)
export(get_subset_array_dispatch)
export(input_check)
export(input_process)
export(is_good_chronogram)
export(make_bladj_tree)
6 changes: 4 additions & 2 deletions R/all_calibrations.R
Original file line number Diff line number Diff line change
@@ -96,9 +96,11 @@ get_all_calibrations <- function(input = c("Rhea americana", "Pterocnemia pennat
#' @export
make_bold_otol_tree <- function(input = c("Rhea americana", "Struthio camelus", "Gallus gallus"), use_tnrs = FALSE, approximate_match = TRUE, marker = "COI", otol_version = "v2", chronogram = TRUE, doML = FALSE, get_spp_from_taxon = FALSE, verbose = FALSE) {
#otol returns error with missing taxa in v3 of rotl
input <- input_check(input = input, use_tnrs = use_tnrs, approximate_match = approximate_match, get_spp_from_taxon = get_spp_from_taxon, verbose = verbose)
input <- datelife_query_check(datelife_query = input, use_tnrs = use_tnrs, approximate_match = approximate_match, get_spp_from_taxon = get_spp_from_taxon, verbose = verbose)
input <- input$cleaned_names
if (verbose) cat("Searching", marker, "sequences for these taxa in BOLD...", "\n")
if (verbose) {
cat("Searching", marker, "sequences for these taxa in BOLD...", "\n")
}
xx <- seq(1, length(input), 250)
yy <- xx+249
yy[length(xx)] <- length(input)
30 changes: 19 additions & 11 deletions R/datelife.R
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ get_datelife_result <- function(input = c("Rhea americana", "Pterocnemia pennata
if(update_cache){
cache <- update_datelife_cache(save = TRUE, verbose = verbose)
}
input <- input_check(input = input, use_tnrs = use_tnrs, approximate_match = approximate_match, get_spp_from_taxon = get_spp_from_taxon, verbose = verbose)
input <- datelife_query_check(datelife_query = input, use_tnrs = use_tnrs, approximate_match = approximate_match, get_spp_from_taxon = get_spp_from_taxon, verbose = verbose)
tree <- input$phy
cleaned_names <- input$cleaned_names
datelife_query_length_check(cleaned_names = cleaned_names, get_spp_from_taxon = get_spp_from_taxon, verbose = verbose)
@@ -120,24 +120,32 @@ get_datelife_result <- function(input = c("Rhea americana", "Pterocnemia pennata
}

#' checks if input is a datelifeQuery object, otherwise it uses make_datelife_query to process it
#' @param datelife_query An object output of make_datelife_query function
#' @inheritParams datelife_search
#' @inheritDotParams make_datelife_query
#' @export
input_check <- function(input = NULL, ...){
if(is.null(input)){
input <- NA
}
if(length(input) == 1 & any(is.na(input))) {
stop("input argument is NULL or NA")
}
datelife_query_check <- function(datelife_query = NULL, ...){
# if(is.null(input)){
# input <- NA
# }
# if(length(input) == 1 & any(is.na(input))) {
# stop("input argument is NULL or NA")
# }
badformat <- TRUE
if(is.list(input) & "phy" %in% names(input) & "cleaned_names" %in% names(input)) {
if(is.list(datelife_query) & "phy" %in% names(datelife_query) & "cleaned_names" %in% names(datelife_query)) {
if(!inherits(datelife_query, "datelifeQuery")) {
class(datelife_query) <- "datelifeQuery"
}
badformat <- FALSE
}
if(badformat){
input <- make_datelife_query(input = input, ...)
datelife_query <- make_datelife_query(input = datelife_query, ...)
badformat <- FALSE
}
return(input)
# if(!badformat){
# # merge datelife_query_length_check function here
# }
return(datelife_query)
}
#' checks that we have at least two taxon names to perform a search
#' @inheritParams datelife_search
5 changes: 0 additions & 5 deletions codecov.yml

This file was deleted.

23 changes: 0 additions & 23 deletions man/input_check.Rd

This file was deleted.

0 comments on commit 38e86e9

Please sign in to comment.