Skip to content

Commit

Permalink
helper function creates hub accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
lgatto committed Mar 17, 2024
1 parent 64e45d8 commit 3014889
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: depmap
Type: Package
Title: Cancer Dependency Map Data Package
Version: 1.17.4
Version: 1.17.5
Authors@R: c(person(given = "Laurent", family = "Gatto",
email = "laurent.gatto@uclouvain.be",
comment = c(ORCID = "0000-0002-1520-2268"),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# depmap 1.17

## Changes in version 1.17.5

- Check if there's internet connectivity before creating hub
accessors.

## Changes in version 1.17.4

- Fix .onLoad() to create Hub accessors for all experiments, including
Expand Down
15 changes: 14 additions & 1 deletion R/loading_functions.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
##' @importFrom utils read.csv
##' @importFrom ExperimentHub createHubAccessors
.createDepMapHubAccessors <- function() {
fls <- dir(system.file("extdata", package = "depmap"),
full.names = TRUE, pattern = "metadata")
sapply(fls,
function(fl) {
titles <- read.csv(fl, stringsAsFactors = FALSE)$Title
ExperimentHub::createHubAccessors(pkgname, titles)
})
}


##' @importFrom AnnotationHub query
##' @importFrom ExperimentHub ExperimentHub

Expand All @@ -9,7 +22,7 @@ depmap_data_loading <- function(name) {
}

#' @export
depmap_rnai <- function()
depmap_rnai <- function()
depmap_data_loading("rnai")

#' @export
Expand Down
15 changes: 3 additions & 12 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
##' @importFrom utils read.csv
##' @importFrom curl has_internet
##' @importFrom ExperimentHub createHubAccessors
.onLoad <- function(libname, pkgname) {
fls <- dir(system.file("extdata", package = pkgname),
full.names = TRUE, pattern = "metadata")
if (curl::has_internet()) {
sapply(fls,
function(fl) {
titles <- read.csv(fl, stringsAsFactors = FALSE)$Title
ExperimentHub::createHubAccessors(pkgname, titles)
})
} else {
if (curl::has_internet())
.createDepMapHubAccessors()
else
warning("Not internet connectivity. Unable to create Hub accessors.",
call. = FALSE)
}
}

.onAttach <- function(libname, pkgname) {
Expand Down

0 comments on commit 3014889

Please sign in to comment.