Default function to download Gesel database files.

downloadDatabaseFile(
  name,
  url = databaseUrl(),
  cache = NULL,
  overwrite = FALSE
)

databaseUrl(url)

Arguments

name

String containing the name of the file. This usually has the species identifier as a prefix.

url

String containing the base URL to the Gesel database files. For databaseUrl, this can be NULL to set it back to the default.

cache

String specifying the path to a cache directory. If NULL, a cache location is automatically chosen.

overwrite

Logical scalar indicating whether any cached file should be overwritten.

Value

downloadDatabaseFile returns a string containing a path to the downloaded file.

For databaseUrl, if url is missing, the function returns a string containing the URL to the Gesel database. If url is provided, it instead stores url as the URL to the database, and the previous value of url is invisibly returned.

Details

The default database URL is set to the GitHub releases at https://github.com/LTLA/gesel-feedstock. This can be altered by setting the GESEL_DATABASE_URL environment variable.

On first use of a cached file in an R session, downloadDatabaseFile will automatically check for updates at url. If the file on the remote has been updated, the new copy will be downloaded to the cache.

Author

Aaron Lun

Examples

# Download file.
downloadDatabaseFile("9606_collections.tsv.gz")
#> [1] "~/.cache/gesel/https%3A%2F%2Fgithub.com%2FLTLA%2Fgesel-feedstock%2Freleases%2Fdownload%2Findices-v0.2.1%2F9606_collections.tsv.gz"

# Altering the default database URL.
databaseUrl()
#> [1] "https://github.com/LTLA/gesel-feedstock/releases/download/indices-v0.2.1"
old <- databaseUrl("https://foo")
databaseUrl()
#> [1] "https://foo"
databaseUrl(old)