#' Converts a series of json files downloaded directly from HMMER into a DataFrame.
#'
#' @param hmmer_json_file A character vector with file paths.
#' @param file_label A character vector with a label with a label to identify the file they come from.
#' @param desc_null A Boolean, TRUE if you want to omit the 'desc' parameter which can cause problems.
#'
#' @return A DataFrame
#' @export
#'
#'
create_hmmer_json_dataframe <- function(hmmer_json_file, file_label,desc_null=TRUE) {
## Check arguments
if(any(!file.exists(hmmer_json_file)))
stop("Invalid file path/s")
if(!is.character(file_label))
stop("'file_label' should be character")
if(length(hmmer_json_file) != length(file_label))
stop("Both vectors should have the same length")
purrr::map2_df(hmmer_json_file, file_label, function(x, y){
x %>%
readr::read_file() %>%
rjson::fromJSON() %>%
purrr::pluck("results") %>%
purrr::pluck("hits") %>%
purrr::map_dfr(~ .x %>%
purrr::when(desc_null ~ purrr::list_modify(.x, "desc" = NULL), .x) %>%
tibble::as_tibble()) %>%
dplyr::mutate(file_label = y)
})}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.