Skip to content

Commit

Permalink
Fix Service creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jwokaty committed Aug 14, 2024
1 parent 5898ada commit 35eee6a
Show file tree
Hide file tree
Showing 21 changed files with 110 additions and 85 deletions.
7 changes: 4 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(.BEDbase)
export(BEDbase)
export(bb_bed_text_search)
export(bb_beds_in_bedset)
export(bb_example)
Expand All @@ -9,9 +9,9 @@ export(bb_list_bedsets)
export(bb_metadata)
export(bb_to_granges)
export(bb_to_grangeslist)
export(bedbaser)
exportClasses(BEDbase)
exportMethods(operations)
importFrom(AnVIL,Service)
importFrom(AnVIL,operations)
importFrom(BiocFileCache,BiocFileCache)
importFrom(BiocFileCache,bfcadd)
importFrom(BiocFileCache,bfccache)
Expand All @@ -24,6 +24,7 @@ importFrom(R.utils,gunzip)
importFrom(dplyr,bind_rows)
importFrom(dplyr,filter)
importFrom(httr,content)
importFrom(methods,callNextMethod)
importFrom(methods,new)
importFrom(purrr,map_depth)
importFrom(rlang,abort)
Expand Down
Empty file removed R/BEDbase-class.R
Empty file.
79 changes: 43 additions & 36 deletions R/bedbaser.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#' BEDbase class
#'
#' @importFrom methods new
#'
#' @export
.BEDbase <- setClass(
"BEDbase",
contains = "Service"
"BEDbase",
contains = "Service"
)

.BEDBASE_API_REFERENCE_VERSION<- "0.5.0"

#' @rdname bedbaser
#' @rdname BEDbase
#'
#' @title An R client for BEDbase
#'
Expand All @@ -20,7 +19,7 @@
#' @details
#'
#' The convenience functions are as follows
#' * `bedbaser::bedbaser()`: API constructor
#' * `bedbaser::BEDbase()`: API service constructor
#' * `bedbaser::bb_example()`: Retrieve an example BED file or BEDset
#' * `bedbaser::bb_metadata()`: Retrieve metadata for a BED file or BEDset
#' * `bedbaser::bb_list_beds()`: List all BED files
Expand All @@ -34,44 +33,52 @@
#'
#' @importFrom AnVIL Service
#'
#' @returns BEDbase object
#' @returns Service object
#'
#' @examples
#' bedbaser()
#' BEDbase()
#'
#' @export
bedbaser <- function() {
BEDbase <- function() {
.BEDbase(
Service(
service = "BEDbase",
host = "api.bedbase.org",
"bedbase",
"api.bedbase.org",
api_reference_version = .BEDBASE_API_REFERENCE_VERSION,
authenticate = FALSE,
api_url = "https://api.bedbase.org/openapi.json",
package = "bedbaser"
package = "bedbaser",
api_reference_url="https://api.bedbase.org/openapi.json",
)
)
}


## Copied from the AnVIL package
.api_header <- function(api) api@api_header

.BEDBASE_API_REFERENCE_VERSION <- "0.5.0"


#' Display API
#'
#' @importFrom AnVIL operations
#' @importFrom methods callNextMethod
#'
#' @examples
#' api <- BEDbase()
#' operations(api)
#'
#' @export
setMethod(
"operations", "BEDbase",
function(x, ..., .deprecated = FALSE) {
callNextMethod(x, ..., .deprecated = .deprecated)
})

#' Get the example BED file or BEDset with metadata
#'
#' @param api API object of BEDbase created from bedbaser()
#' @param api API object of BEDbase created from BEDbase()
#' @param rec_type character() bed or bedset
#'
#' @importFrom httr content
#'
#' @returns list() bed or bedset
#'
#' @examples
#' api <- bedbaser()
#' api <- BEDbase()
#' bb_example(api, "bed")
#' bb_example(api, "bedset")
#'
Expand All @@ -93,7 +100,7 @@ bb_example <- function(api, rec_type = c("bed", "bedset")) {
#'
#' @rdname bb_metadata
#'
#' @param api API object of BEDbase created from bedbaser()
#' @param api API object of BEDbase created from BEDbase()
#' @param id integer() record or object identifier
#' @param full logical() (default FALSE) include full record with stats, files,
#' and metadata
Expand All @@ -104,7 +111,7 @@ bb_example <- function(api, rec_type = c("bed", "bedset")) {
#' @returns list() metadata
#'
#' @examples
#' api <- bedbaser()
#' api <- BEDbase()
#'
#' ex_bed <- bb_example(api, "bed")
#' bb_metadata(api, ex_bed$id)
Expand Down Expand Up @@ -138,7 +145,7 @@ bb_metadata <- function(api, id, full = FALSE) {
#'
#' @rdname bb_list_beds
#'
#' @param api API object of BEDbase created from bedbaser()
#' @param api API object of BEDbase created from BEDbase()
#' @param genome character() (default NULL) genome keyword
#' @param bed_type character() (default NULL) bed file type
#' @param limit integer() (default 1000) maximum records
Expand All @@ -151,7 +158,7 @@ bb_metadata <- function(api, id, full = FALSE) {
#' @returns tibble() of BED records
#'
#' @examples
#' api <- bedbaser()
#' api <- BEDbase()
#' bb_list_beds(api)
#'
#' @export
Expand All @@ -177,7 +184,7 @@ bb_list_beds <- function(api, genome = NULL, bed_type = NULL, limit = 1000,
#'
#' @rdname bb_list_bedsets
#'
#' @param api API object of BEDbase created from bedbaser()
#' @param api API object of BEDbase created from BEDbase()
#' @param query character() (default NULL) keyword
#' @param limit integer() (default 1000) maximum records of bedsets
#' @param offset integer() (default 0) page token of records
Expand All @@ -190,7 +197,7 @@ bb_list_beds <- function(api, genome = NULL, bed_type = NULL, limit = 1000,
#' @returns tibble() of BEDset records
#'
#' @examples
#' api <- bedbaser()
#' api <- BEDbase()
#' bb_list_bedsets(api)
#'
#' @export
Expand All @@ -213,7 +220,7 @@ bb_list_bedsets <- function(api, query = NULL, limit = 1000, offset = 0) {
#'
#' @rdname bb_beds_in_bedset
#'
#' @param api API object of BEDbase created from bedbaser()
#' @param api API object of BEDbase created from BEDbase()
#' @param bedset_id integer() BEDset record identifier
#'
#' @importFrom httr content
Expand All @@ -223,7 +230,7 @@ bb_list_bedsets <- function(api, query = NULL, limit = 1000, offset = 0) {
#' @returns list() BED record identifiers
#'
#' @examples
#' api <- bedbaser()
#' api <- BEDbase()
#' ex_bedset <- bb_example(api, "bedset")
#' bb_beds_in_bedset(api, ex_bedset$id)
#'
Expand All @@ -246,7 +253,7 @@ bb_beds_in_bedset <- function(api, bedset_id) {
#'
#' @rdname bb_bed_text_search
#'
#' @param api API object of BEDbase created from bedbaser()
#' @param api API object of BEDbase created from BEDbase()
#' @param query character() keywords to search
#' @param limit integer() (default 10) maximum number of results
#' @param offset integer() (default 0) page offset of results
Expand All @@ -260,7 +267,7 @@ bb_beds_in_bedset <- function(api, bedset_id) {
#' @returns tibble()
#'
#' @examples
#' api <- bedbaser()
#' api <- BEDbase()
#' bb_bed_text_search(api, "hg38")
#'
#' @export
Expand All @@ -286,7 +293,7 @@ bb_bed_text_search <- function(api, query, limit = 10, offset = 0) {
#'
#' @rdname bb_to_granges
#'
#' @param api API object of BEDbase created from bedbaser()
#' @param api API object of BEDbase created from BEDbase()
#' @param bed_id integer() BED record identifier
#' @param file_type character() bed or bigbed
#' @param extra_cols character() (default NULL) extra column names to
Expand All @@ -301,7 +308,7 @@ bb_bed_text_search <- function(api, query, limit = 10, offset = 0) {
#' @returns GRanges() object
#'
#' @examples
#' api <- bedbaser()
#' api <- BEDbase()
#' ex_bed <- bb_example(api, "bed")
#' bb_to_granges(api, ex_bed$id)
#'
Expand All @@ -327,7 +334,7 @@ bb_to_granges <- function(api, bed_id, file_type = "bed", extra_cols = NULL,
#'
#' @rdname bb_to_grangeslist
#'
#' @param api API object of BEDbase created from bedbaser()
#' @param api API object of BEDbase created from BEDbase()
#' @param bedset_id integer() BEDset record identifier
#' @param quietly logical() (default TRUE) display messages
#'
Expand All @@ -336,7 +343,7 @@ bb_to_granges <- function(api, bed_id, file_type = "bed", extra_cols = NULL,
#' @returns GRangesList() object
#'
#' @examples
#' api <- bedbaser()
#' api <- BEDbase()
#' id <- "lola_hg38_ucsc_features"
#' bb_to_grangeslist(api, id)
#'
Expand Down
2 changes: 1 addition & 1 deletion inst/service/README.md → inst/service/bedbase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ Convert openapi.json from OpenAPI 3.1 to 3.0:
Convert from OpenAPI 3.0 to Swagger 2.0 and render in YAML:

api-spec-converter -f openapi_3 -t swagger_2 openapi_3_0.json \
--syntax yaml > openapi.yaml
--syntax yaml > api.yaml
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions man/bedbaser.Rd → 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_bed_text_search.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_beds_in_bedset.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_example.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_list_beds.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_list_bedsets.Rd

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

Loading

0 comments on commit 35eee6a

Please sign in to comment.