Skip to content

Commit

Permalink
fix getHSDSFileList
Browse files Browse the repository at this point in the history
  • Loading branch information
assaron committed Jul 22, 2024
1 parent 236c8d2 commit 3e4299f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", role = c("aut", "cre")))
Expand Down
51 changes: 25 additions & 26 deletions R/getHSDSFileList.R
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
}

0 comments on commit 3e4299f

Please sign in to comment.