Skip to contents

Filters the versions based on multiple conditions: their age and status

Usage

omnipath_cache_filter_versions(
  record,
  latest = FALSE,
  max_age = NULL,
  min_age = NULL,
  status = CACHE_STATUS$READY
)

Arguments

record

A cache record

latest

Return the most recent version

max_age

The maximum age in days (e.g. 5: 5 days old or more recent)

min_age

The minimum age in days (e.g. 5: 5 days old or older)

status

Character vector with status codes. By default only the versions with `ready` (completed download) status are selected

Value

Character vector with version IDs, NA if no version satisfies the conditions.

Examples

# creating an example cache record
bioc_url <- 'https://bioconductor.org/'
version <- omnipath_cache_latest_or_new(url = bioc_url)
httr::GET(bioc_url, httr::write_disk(version$path, overwrite = TRUE))
#> Response [https://bioconductor.org/]
#>   Date: 2024-04-07 15:20
#>   Status: 200
#>   Content-Type: text/html
#>   Size: 37.3 kB
#> <ON DISK>  /home/denes/.cache/OmnipathR/41346a00fb20d2a9df03aa70cf4d50bf88ab154a-1
omnipath_cache_download_ready(version)
record <- dplyr::first(omnipath_cache_search('biocond'))

# only the versions with status "ready"
version_numbers <- omnipath_cache_filter_versions(record, status = 'ready')
omnipath_cache_remove(url = bioc_url) # cleaning up