diff --git a/R/ncbi_download_genome.R b/R/ncbi_download_genome.R index b664a0e..480513c 100644 --- a/R/ncbi_download_genome.R +++ b/R/ncbi_download_genome.R @@ -40,6 +40,7 @@ ncbi_download_genome <- function(query, type = "genomic.gbff", dirpath = NULL, + filename = NULL, mirror = TRUE, verbose = getOption("verbose")) { type <- match.arg(type, c( @@ -104,6 +105,8 @@ ncbi_download_genome <- function(query, translated_cds = ".faa.gz") urlpath <- paste0(ftppath, "/", prefix, "_" ,type, suffix) if (is.null(dirpath)) dirpath = getwd() + if (is.null(filename)) filename = basename(urlpath) + if (mirror) { dirpath <- gsub( "ftp://ftp.ncbi.nlm.nih.gov/genomes", @@ -112,7 +115,8 @@ ncbi_download_genome <- function(query, ) } if (!dir.exists(dirpath)) dir.create(dirpath, recursive = TRUE) - filepath <- paste0(dirpath, "/", basename(urlpath)) + filepath <- paste0(dirpath, "/", filename) + if (file.exists(filepath)) { if (verbose) message("Done. Already downloaded.") return(NA)