From ca6ffd3f63c73caa514dba3e1e7ad6b14520f234 Mon Sep 17 00:00:00 2001 From: chainsawriot Date: Thu, 23 Feb 2023 13:46:09 +0100 Subject: [PATCH] Fix #69 --- DESCRIPTION | 3 ++- R/memo_misc.R | 19 +++++++++++++++---- tests/testthat/test_resolve.R | 12 +++++++++++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ef76222..2c5153f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,7 +26,8 @@ Imports: pkgsearch, remotes, utils, - gh + gh, + vctrs Depends: R (>= 3.5.0) VignetteBuilder: knitr diff --git a/R/memo_misc.R b/R/memo_misc.R index f099a88..907df84 100644 --- a/R/memo_misc.R +++ b/R/memo_misc.R @@ -34,10 +34,21 @@ NULL if (bioc_version != "release" && utils::compareVersion(bioc_version, "2.0") == -1) { stop("Bioconductor versions < 2.0 are not supported.", call. = FALSE) } - con <- url(paste0("http://bioconductor.org/packages/", bioc_version, "/bioc/VIEWS")) - pkgs <- read.dcf(con) - close(con) - as.data.frame(pkgs) + suffixes <- c("bioc", "data/annotation", "data/experiment", "workflow") + output <- data.frame() + for (suffix in suffixes) { + view_url <- paste0("http://bioconductor.org/packages/", bioc_version, "/", suffix, "/VIEWS") + con <- url(view_url) + tryCatch({ + raw_metadata <- suppressWarnings(read.dcf(con)) + metadata <- as.data.frame(raw_metadata) + output <- vctrs::vec_rbind(output, metadata) + close(con) + }, error = function(e) { + close(con) + }) + } + output } .memo_search_bioc <- memoise::memoise(.bioc_package_history, cache = cachem::cache_mem(max_age = 60 * 60)) diff --git a/tests/testthat/test_resolve.R b/tests/testthat/test_resolve.R index e13ec6e..0043c20 100644 --- a/tests/testthat/test_resolve.R +++ b/tests/testthat/test_resolve.R @@ -179,8 +179,18 @@ test_that("issue 68, correct querying of bioc packages from major releases", { skip_on_cran() expect_equal(.query_biocver("2007-04-27")$version, "2.0") expect_false(is.numeric(.query_biocver("2007-04-27")$version)) - expect_error(.query_snapshot_dependencies_bioc("affy", "2014-10-15"), NA) + expect_error(.query_snapshot_dependencies_bioc("affy", "2007-04-15")) ## pre 2.0 + expect_error(.query_snapshot_dependencies_bioc("affy", "2007-04-27"), NA) expect_error(.query_snapshot_dependencies_bioc("affy", "2014-10-15"), NA) expect_equal(length(resolve("bioc::affy", snapshot_date = "2007-04-27")$ranglets), 1) expect_equal(length(resolve("bioc::affy", snapshot_date = "2014-10-15")$ranglets), 1) }) + +test_that("issue 69, complete bioc information", { + skip_if_offline() + skip_on_cran() + expect_true(nrow(.memo_search_bioc("3.3")) > 1211) + expect_true("affydata" %in% .memo_search_bioc("3.3")$Package) + expect_equal(.normalize_pkg("affydata", "3.3"), "bioc::affydata") + expect_equal(length(resolve("bioc::affydata", snapshot_date = "2016-06-15")$ranglets), 1) +})