Skip to content

Commit 8643a59

Browse files
committed
Catch improper UniProt IDs
1 parent 05c4032 commit 8643a59

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

R/fetch_interpro.R

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ fetch_interpro <- function(uniprot_ids = NULL,
126126
# Store the results from the current page
127127
all_results[[current_page]] <- query
128128

129-
130129
# initialize progress bar
131130
if (show_progress == TRUE & current_page == 1 & length(query_url_part) == 1 & (!is(query, "character") && !is.null(query$count))) {
132131
pb <- progress::progress_bar$new(
@@ -169,23 +168,41 @@ fetch_interpro <- function(uniprot_ids = NULL,
169168
}
170169
}
171170

171+
# check if any querys were not completed and give a message about them
172+
if(exists("query_result") && any(purrr::map_lgl(query_result, .f = ~ {length(.x) == 0}))){
173+
problematic_ids <- uniprot_ids[purrr::map_lgl(query_result, .f = ~ {length(.x) == 0})]
174+
175+
message("\nThe following IDs do not exist in the InterPro database:\n", paste0(problematic_ids, collapse = "\n"))
176+
}
177+
172178
# If any element is character stop the function and report the issue
173179
if (exists("query_result") && any(purrr::map_lgl(query_result, .f = ~ {
174-
purrr::map_lgl(.x, is.character)
180+
if (length(.x) == 0){
181+
FALSE
182+
} else {
183+
purrr::map_lgl(.x, is.character)
184+
}
175185
}))) {
176186
problematic_ids <- uniprot_ids[purrr::map_lgl(query_result, .f = ~ {
177-
any(purrr::map_lgl(.x, is.character))
187+
if (length(.x) == 0){
188+
FALSE
189+
} else {
190+
any(purrr::map_lgl(.x, is.character))
191+
}
178192
})]
179193
issue <- purrr::keep(query_result, .p = ~ {
180-
purrr::map_lgl(.x, is.character)
194+
if (length(.x) == 0){
195+
FALSE
196+
} else {
197+
purrr::map_lgl(.x, is.character)
198+
}
181199
}) %>%
182200
unlist()
183201

184202
message("\nThere was an issue fetching from InterPro:\n", paste0(problematic_ids, ": ", issue, "\n"))
185203
return(NULL)
186204
}
187205

188-
189206
# if residue level information should be returned, fetch it here
190207
if (return_residue_info) {
191208
query_residue <- purrr::map_dfr(
@@ -340,5 +357,5 @@ fetch_interpro <- function(uniprot_ids = NULL,
340357
}
341358
)
342359

343-
domain_result
360+
return(domain_result)
344361
}

0 commit comments

Comments
 (0)