Skip to content

Commit

Permalink
Code tidy-up
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekGierlinski committed Dec 14, 2023
1 parent 9669064 commit e59c3e4
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 24 deletions.
8 changes: 1 addition & 7 deletions R/go.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ extract_obo_terms <- function(parsed) {
#' @return A tibble with term_id and term_name.
#' @noRd
fetch_go_terms <- function(use_cache, on_error = "stop") {
# Temporary patch to circumvent vroom 1.6.4 bug
# readr::local_edition(1)

obo_file <- get_go_obo_file()
if(!assert_url_path(obo_file, on_error))
return(NULL)
Expand Down Expand Up @@ -175,15 +172,12 @@ fetch_go_genes_go <- function(species, use_cache, on_error = "stop") {
gene_synonym <- db_object_synonym <- symbol <- NULL
db_id <- go_term <- NULL

# Temporary patch to circumvent vroom 1.6.4 bug
# readr::local_edition(1)

url <- get_go_annotation_url()
gaf_file <- stringr::str_glue("{url}/{species}.gaf.gz")
if(!assert_url_path(gaf_file, on_error))
return(NULL)

lpath <- cached_url_path(stringr::str_glue("gaf_{species}"), gaf_file, use_cache)
lpath <- cached_url_path(stringr::str_glue("go_gaf_{species}"), gaf_file, use_cache)
readr::read_tsv(lpath, comment = "!", quote = "", col_names = GAF_COLUMNS,
col_types = GAF_TYPES) |>
dplyr::mutate(gene_synonym = stringr::str_remove(db_object_synonym, "\\|.*$")) |>
Expand Down
7 changes: 0 additions & 7 deletions R/kegg.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ get_kegg_url <- function() {
#' @examples
#' spe <- fetch_kegg_species()
fetch_kegg_species <- function(on_error = c("stop", "warn")) {

# Temporary patch to circumvent vroom 1.6.4 bug
# readr::local_edition(1)

qry <- api_query(get_kegg_url(), "list/organism")
if(qry$is_error)
return(catch_error("KEGG", qry$response, on_error))
Expand All @@ -47,9 +43,6 @@ fetch_kegg_pathways <- function(species, on_error) {
# Binding variables from non-standard evaluation locally
term_id <- NULL

# Temporary patch to circumvent vroom 1.6.4 bug
# readr::local_edition(1)

qry <- api_query(get_kegg_url(), stringr::str_glue("list/pathway/{species}"))
if(qry$is_error)
return(catch_error("KEGG", qry$response, on_error))
Expand Down
6 changes: 0 additions & 6 deletions R/reactome.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ fetch_reactome_ensembl_genes <- function(spec, use_cache = TRUE, on_error = "sto
# Binding variables from non-standard evaluation locally
species <- gene_id <- term_id <- NULL

# Temporary patch to circumvent vroom 1.6.4 bug
# readr::local_edition(1)

ensembl_file <- get_reactome_ensembl_file()
if(!assert_url_path(ensembl_file, on_error))
return(NULL)
Expand Down Expand Up @@ -130,9 +127,6 @@ fetch_reactome_gene_association <- function(tax_id, use_cache = TRUE, on_error =
# Binding variables from non-standard evaluation locally
symbol <- taxon <- db_ref <- db_id <- NULL

# Temporary patch to circumvent vroom 1.6.4 bug
# readr::local_edition(1)

gaf_file <- get_reactome_gaf_file()
if(!assert_url_path(gaf_file, on_error))
return(NULL)
Expand Down
1 change: 1 addition & 0 deletions R/util.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Gene Annotation File column names. GAF is used by GO and Reactome.
GAF_COLUMNS <- c(
"db",
"db_id",
Expand Down
File renamed without changes.
5 changes: 1 addition & 4 deletions tests/testthat/test_kegg.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ test_that("Incorrect batch size in fetch_kegg", {


test_that("Parsing KEGG flat file", {
# Temporary patch to circumvent vroom 1.6.4 bug
# readr::local_edition(1)

flat <- readr::read_file("../test_data/kegg_test.txt")
expected <- readr::read_rds("../test_data/kegg_parseing_result.rds")
expected <- readr::read_rds("../test_data/kegg_parsing_result.rds")
parsed <- parse_kegg_genes(flat)
expect_equal(parsed, expected)
})
Expand Down

0 comments on commit e59c3e4

Please sign in to comment.