Skip to content

Commit

Permalink
Unset robot_query() character col type assumption
Browse files Browse the repository at this point in the history
Also add col_types from readr::read_tsv() for management. To
reduce verbosity, show_col_types has been set to FALSE and
cannot be changed.

Tests (robot_wrappers): PASS
  • Loading branch information
allenbaron committed Feb 15, 2024
1 parent 40f3107 commit 3e1dc06
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 7 deletions.
7 changes: 4 additions & 3 deletions R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ extract_as_tidygraph <- function(x, query = NULL, collapse_method = "first",
#'
#' @param output The path where output will be written, as a string, or `NULL`
#' (default) to load data directly.
#' @inheritParams tidy_sparql
#' @inheritParams robot_query
#'
#' @returns
#' If `output` is specified, the path to the output file with the data.
Expand All @@ -482,7 +482,7 @@ extract_as_tidygraph <- function(x, query = NULL, collapse_method = "first",
#'
#' @export
extract_ordo_mappings <- function(ordo_path, as_skos = TRUE, output = NULL,
tidy_what = "everything") {
tidy_what = "everything", col_types = NULL) {
if (isTRUE(as_skos)) {
q_nm <- "mapping-ordo-skos.rq"
} else {
Expand All @@ -494,7 +494,8 @@ extract_ordo_mappings <- function(ordo_path, as_skos = TRUE, output = NULL,
input = ordo_path,
query = q_file,
output = output,
tidy_what = tidy_what
tidy_what = tidy_what,
col_types = col_types
)

out
Expand Down
6 changes: 4 additions & 2 deletions R/robot_wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ convert_to_ofn <- function(path, out_path = NULL, gzip = FALSE,
#' [ROBOT query](http://robot.obolibrary.org/query) formatted as described in
#' [DO.utils::robot()].
#' @inheritParams tidy_sparql
#' @inheritParams readr::read_tsv
#'
#' @returns
#' If `output` is specified, the path to the output file with the query result.
Expand All @@ -60,7 +61,7 @@ convert_to_ofn <- function(path, out_path = NULL, gzip = FALSE,
#'
#' @export
robot_query <- function(input, query, output = NULL, ...,
tidy_what = "nothing") {
tidy_what = "nothing", col_types = NULL) {
# load query, also ensure query in a file (required by ROBOT)
query_is_file <- file.exists(query)
if (query_is_file) {
Expand Down Expand Up @@ -121,7 +122,8 @@ robot_query <- function(input, query, output = NULL, ...,
} else {
out <- readr::read_tsv(
output,
col_types = readr::cols(.default = readr::col_character())
col_types = col_types,
show_col_types = FALSE
)
out <- tidy_sparql(out, tidy_what)
}
Expand Down
35 changes: 34 additions & 1 deletion man/extract_ordo_mappings.Rd

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

41 changes: 40 additions & 1 deletion man/robot_query.Rd

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

0 comments on commit 3e1dc06

Please sign in to comment.