Skip to content

Commit

Permalink
Fix #15 and release 1.2.8
Browse files Browse the repository at this point in the history
Minor update
  • Loading branch information
ShixiangWang committed Nov 17, 2019
1 parent b716b21 commit 170e038
Show file tree
Hide file tree
Showing 16 changed files with 145 additions and 73 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ License: GPL-3
Encoding: UTF-8
LazyData: true
VignetteBuilder: knitr
RoxygenNote: 6.1.1
RoxygenNote: 7.0.0
Roxygen: list(markdown = TRUE)
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Bug fixes

* #14 fixed
* #15 fixed

# v1.2.7

Expand Down
41 changes: 22 additions & 19 deletions R/XenaDownload.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ XenaDownload <- function(xquery,
xquery$destfiles <- file.path(destdir, xquery$fileNames)

if (!dir.exists(destdir)) {
dir.create(destdir, recursive = TRUE)
dir.create(destdir, recursive = TRUE, showWarnings = FALSE)
}

message("All downloaded files will under directory ", destdir, ".")
Expand All @@ -66,30 +66,33 @@ XenaDownload <- function(xquery,
message("The 'trans_slash' option is FALSE, keep same directory structure as Xena.")
message("Creating directories for datasets...")
for (i in dir_names) {
dir.create(i, recursive = TRUE)
dir.create(i, recursive = TRUE, showWarnings = FALSE)
}
}

apply(xquery, 1, function(x) { # nocov start
tryCatch({
if (!file.exists(x[5]) | force) {
message("Downloading ", x[4])
tryCatch(
{
if (!file.exists(x[5]) | force) {
message("Downloading ", x[4])
download.file(x[3], destfile = x[5], ...)
} else {
message(x[5], ", the file has been download!")
}
},
error = function(e) {
message(
"Can not find file",
x[4],
", this file maybe not compressed."
)
x[3] <- gsub(pattern = "\\.gz$", "", x[3])
x[4] <- gsub(pattern = "\\.gz$", "", x[4])
x[5] <- gsub(pattern = "\\.gz$", "", x[5])
message("Try downloading file", x[4], "...")
download.file(x[3], destfile = x[5], ...)
} else {
message(x[5], ", the file has been download!")
}
}, error = function(e) {
message(
"Can not find file",
x[4],
", this file maybe not compressed."
)
x[3] <- gsub(pattern = "\\.gz$", "", x[3])
x[4] <- gsub(pattern = "\\.gz$", "", x[4])
x[5] <- gsub(pattern = "\\.gz$", "", x[5])
message("Try downloading file", x[4], "...")
download.file(x[3], destfile = x[5], ...)
})
)
}) # nocov end

if (trans_slash) {
Expand Down
8 changes: 5 additions & 3 deletions R/XenaHub-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ XenaDataUpdate <- function(saveTolocal = TRUE) { # nocov start
}
}

utils::globalVariables(c(".p_dataset_metadata",
".p_all_cohorts",
".p_dataset_list"))
utils::globalVariables(c(
".p_dataset_metadata",
".p_all_cohorts",
".p_dataset_list"
))
9 changes: 6 additions & 3 deletions R/api_higher.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@
##' @return a character vector contains hosts
##' @export
##' @examples xe = XenaGenerate(subset = XenaHostNames == "tcgaHub"); hosts(xe)
hosts <- function(x)
hosts <- function(x) {
unname(slot(x, "hosts"))
}
##' Get cohorts of XenaHub object
##' @param x a [XenaHub] object
##' @return a character vector contains cohorts
##' @importFrom methods slot
##' @export
##' @examples xe = XenaGenerate(subset = XenaHostNames == "tcgaHub"); cohorts(xe)
cohorts <- function(x)
cohorts <- function(x) {
slot(x, "cohorts")
}
##' Get datasets of XenaHub object
##' @param x a [XenaHub] object
##' @return a character vector contains datasets
##' @importFrom methods slot
##' @export
##' @examples xe = XenaGenerate(subset = XenaHostNames == "tcgaHub"); datasets(xe)
datasets <- function(x)
datasets <- function(x) {
slot(x, "datasets")
}

##' Get Samples of a XenaHub object according to 'by' and 'how' action arguments
##'
Expand Down
36 changes: 22 additions & 14 deletions R/api_inner.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

.null_cohort <- "(unassigned)"

.quote <- function(s)
.quote <- function(s) {
paste0('"', s, '"')
}

.quote_cohort <- function(cohort) {
ifelse(cohort == .null_cohort, "nil", .quote(cohort))
Expand All @@ -25,8 +26,9 @@
paste0(.quote(l), collapse = collapse)
}

.collapse_cohort <- function(cohorts, collapse = " ")
.collapse_cohort <- function(cohorts, collapse = " ") {
paste0(.quote_cohort(cohorts), collapse = collapse)
}

.arrayfmt <- function(l, collapse = .collapse) {
paste0("[", collapse(l), "]")
Expand Down Expand Up @@ -83,7 +85,7 @@

## samples

.samples_any_query <- function(what)
.samples_any_query <- function(what) {
paste0(
"\n (map :value\n (query {\n :select [:%distinct.value]\n :from [:dataset]\n :join [:field [:= :dataset.id :dataset_id]\n :code [:= :field_id :field.id]]\n :where [:and\n [:in ",
what,
Expand All @@ -92,8 +94,9 @@
}))
'
)
}

.samples_all_query <- function(where, what, n) # nocov start
.samples_all_query <- function(where, what, n) { # nocov start
paste0(
"\n (map :value\n (query {\n :select [:value] :from [{\n :select [",
where,
Expand All @@ -109,7 +112,8 @@
:having [:= :%count.value ',
n,
"]\n }))\n "
) # nocov end
)
} # nocov end


##
Expand All @@ -120,13 +124,16 @@
# host --------------------------------------------------------------------

.host_is_alive <- function(host) {
tryCatch({
result <- .xena_post(host, "(+ 1 2)")
stop_for_status(result)
TRUE
}, error = function(...) {
FALSE
})
tryCatch(
{
result <- .xena_post(host, "(+ 1 2)")
stop_for_status(result)
TRUE
},
error = function(...) {
FALSE
}
)
}

.host_cohorts <- function(hosts) {
Expand Down Expand Up @@ -227,8 +234,9 @@
how,
each = x,
any = unique(unlist(x, use.names = FALSE)),
all = Reduce(function(x, y)
x[x %in% y], x)
all = Reduce(function(x, y) {
x[x %in% y]
}, x)
)
}

Expand Down
4 changes: 2 additions & 2 deletions man/XenaBrowse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions man/XenaDownload.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions man/XenaFilter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions man/XenaHub.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions man/XenaPrepare.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions man/XenaScan.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions man/downloadTCGA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions man/fetch.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 23 additions & 9 deletions man/getTCGAdata.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 170e038

Please sign in to comment.