From 3e4299f3be7dbbf90115a3bb0f50e205ebdf5fd6 Mon Sep 17 00:00:00 2001 From: Alexey Sergushichev Date: Mon, 22 Jul 2024 14:32:56 -0500 Subject: [PATCH] fix getHSDSFileList --- DESCRIPTION | 2 +- R/getHSDSFileList.R | 51 ++++++++++++++++++++++----------------------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e18216b..1cd2a4e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: phantasusLite Type: Package Title: Loading and annotation RNA-seq counts matrices -Version: 1.3.0 +Version: 1.3.2 Authors@R: c(person("Rita", "Sablina", role = "aut"), person("Maxim", "Kleverov", role = "aut"), person("Alexey", "Sergushichev", email = "alsergbox@gmail.com", role = c("aut", "cre"))) diff --git a/R/getHSDSFileList.R b/R/getHSDSFileList.R index 03011a1..9187dc2 100755 --- a/R/getHSDSFileList.R +++ b/R/getHSDSFileList.R @@ -1,3 +1,22 @@ +listDomainFiles <- function(src, directory) { + request <- paste0(src@endpoint, "/domains?domain=", directory) + response <- rhdf5client:::submitRequest(request) + domains <- response[["domains"]] + + res <- lapply(domains, function(d) { + if (d$class == "domain") { + return(d$name) + } + + stopifnot(d$class == "folder") + return(c(d$name, + listDomainFiles(src, d$name))) + }) + res <- unlist(res) + res +} + + #' Returns list of all HDF5-files on HSDS-server #' @param url, containing url of the server and root domain. #' @param directory, containing name of the directory @@ -13,36 +32,16 @@ getHSDSFileList <- function(url='https://alserglab.wustl.edu/hsds/?domain=/counts', directory = NULL) { src <- httr::parse_url(url) - dir <- src$query$domain + root <- src$query$domain src <- paste0(src$scheme,'://',src$hostname,'/',src$path) src <- HSDSSource(src) - hdf5FileList <- list() if (is.null(directory)) { - directories <- listDomains(src, dir) - directories <- directories[-grep("*\\.h5$", directories)] - directories <- gsub(paste0(dir, '/'), '', directories) - for (directory in directories) { - request <- paste0(src@endpoint, "/domains?domain=", - dir, '/', directory) - response <- rhdf5client:::submitRequest(request) - domains <- response[["domains"]] - for (domain in domains) { - if (domain$name != paste0(dir, "/", directory, '/', directory, ".h5")) { - hdf5FileList <- append(hdf5FileList, domain$name) - } - } - } + directory <- root } else { - request <- paste0(src@endpoint, "/domains?domain=", - dir, '/', directory) - response <- rhdf5client:::submitRequest(request) - domains <- response[["domains"]] - for (domain in domains) { - if (domain$name != paste0(dir, "/", directory, '/', directory, ".h5")) { - hdf5FileList <- append(hdf5FileList, domain$name) - } - } + directory <- paste0(root, "/", directory) } - hdf5FileList <- unlist(hdf5FileList) + + hdf5FileList <- listDomainFiles(src, directory) + hdf5FileList <- grep(".*\\.h5$", hdf5FileList, value = TRUE) return(hdf5FileList) }