Skip to content

Commit

Permalink
Fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
jwokaty committed Jan 3, 2025
1 parent 59fe2e1 commit 6ab027b
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: bedbaser
Title: A BEDbase client
Version: 0.99.15
Version: 0.99.16
Authors@R: c(
person(
given = "Jen",
Expand Down
9 changes: 4 additions & 5 deletions R/bedbaser.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#' @examples
#' api <- BEDbase(cache_path = tempdir())
#' ex_bed <- bb_example(api, "bed")
#' ex_bed_md <- bb_metadata(api, "bed")
#' bb_metadata(api, ex_bed$id)
#'
#' @export
BEDbase <- function(cache_path, quietly = FALSE) {
Expand Down Expand Up @@ -415,8 +415,7 @@ bb_to_granges <- function(
#'
#' @examples
#' api <- BEDbase()
#' id <- "lola_hg38_ucsc_features"
#' bb_to_grangeslist(api, id)
#' bb_to_grangeslist(api, "lola_hg38_ucsc_features")
#'
#' @export
bb_to_grangeslist <- function(api, bedset_id, quietly = TRUE) {
Expand Down Expand Up @@ -444,8 +443,8 @@ bb_to_grangeslist <- function(api, bedset_id, quietly = TRUE) {
#'
#' @examples
#' api <- BEDbase()
#' ex <- bb_example(api, "bed")
#' bb_save(api, ex$id, tempdir())
#' ex_bed <- bb_example(api, "bed")
#' bb_save(api, ex_bed$id, tempdir())
#'
#' @export
bb_save <- function(
Expand Down
12 changes: 5 additions & 7 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@
#' .get_file(md, tempdir(), "bed", "http")
#'
#' @noRd
.get_file <- function(
metadata, cache_or_path, file_type = c("bed", "bigbed"),
access_type = c("s3", "http"), quietly = TRUE) {
.get_file <- function(metadata, cache_or_path, file_type = c("bed", "bigbed"),
access_type = c("s3", "http"), quietly = TRUE) {
file_details <- .format_metadata_files(metadata$files) |>
dplyr::filter(
name == paste(file_type, "file", sep = "_"),
access_id == access_type
)
if (is(cache_or_path, "BiocFileCache")) {
if (methods::is(cache_or_path, "BiocFileCache")) {
cached_file <- .download_to_cache(
metadata$id, file_details$url,
cache_or_path, quietly
Expand Down Expand Up @@ -153,9 +152,8 @@
#' .bed_file_to_granges(file_path, md)
#'
#' @noRd
.bed_file_to_granges <- function(
file_path, metadata, extra_cols = NULL,
quietly = TRUE) {
.bed_file_to_granges <- function(file_path, metadata, extra_cols = NULL,
quietly = TRUE) {
args <- list(con = file_path)
args["format"] <- gsub("peak", "Peak", metadata$bed_format)
nums <- stringr::str_replace(metadata$bed_type, "bed", "") |>
Expand Down
2 changes: 1 addition & 1 deletion man/BEDbase.Rd

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

4 changes: 2 additions & 2 deletions man/bb_save.Rd

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

3 changes: 1 addition & 2 deletions man/bb_to_grangeslist.Rd

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

8 changes: 4 additions & 4 deletions tests/testthat/test-bedbaser.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ test_that("bb_to_granges returns a GRanges object given a 3+0 bed file", {
md <- bb_metadata(api, id, TRUE)
expect_equal("bed3+0", md$bed_type)
gro <- bb_to_granges(api, id)
expect_true(is((gro)[1], "GRanges"))
expect_true(methods::is((gro)[1], "GRanges"))
})

test_that("bb_to_granges returns a GRanges object given a bigbed file", {
api <- BEDbase(quietly = TRUE)
id <- "ffc1e5ac45d923135500bdd825177356"
if (.Platform$OS.type != "windows") {
gro <- bb_to_granges(api, id, "bigbed")
expect_true(is((gro)[1], "GRanges"))
expect_true(methods::is((gro)[1], "GRanges"))
} else {
expect_warning(
rlang::warn("This feature does not work on Windows."),
Expand All @@ -121,7 +121,7 @@ test_that("bb_to_granges returns a GRanges object given narrowpeak (6+4) file",
md <- bb_metadata(api, id, TRUE)
expect_equal("bed6+4", md$bed_type)
gro <- bb_to_granges(api, id)
expect_true(is((gro)[1], "GRanges"))
expect_true(methods::is((gro)[1], "GRanges"))
df <- as.data.frame(gro)
expect_contains(
c(
Expand Down Expand Up @@ -170,7 +170,7 @@ test_that("bb_to_granges allows passing extra_cols", {
test_that("bb_to_grangeslist creates a GRangesList", {
api <- BEDbase(quietly = TRUE)
grl <- bb_to_grangeslist(api, "lola_hg38_ucsc_features")
expect_true(is((grl)[1], "CompressedGRangesList"))
expect_true(methods::is((grl)[1], "CompressedGRangesList"))
expect_equal(11, length(grl))
})

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_that(".format_metadata_files returns a tibble with a url column", {
ex_bed <- bb_example(api, "bed")
ex_md <- bb_metadata(api, ex_bed$id, TRUE)
mdf <- .format_metadata_files(ex_md$files)
expect_true(is((mdf)[1], "tbl_df"))
expect_true(methods::is((mdf)[1], "tbl_df"))
expect_true("url" %in% names(mdf))
})

Expand Down

0 comments on commit 6ab027b

Please sign in to comment.