R/helper_functions.R

Defines functions get_last_two_elements_of_path get_janno_file_paths

get_janno_file_paths <- function(path) {
  lapply(
    path, function(x) {
      if (strsplit(x, "\\.") %>% unlist %>% utils::tail(1) == "janno") {
        checkmate::assert_file_exists(x)
        return(x)
      } else {
        checkmate::assert_directory_exists(x)
        return(list.files(x, pattern = "\\.janno", full.names = T, recursive = T))
      }
    }
  ) %>% unlist()
}

get_last_two_elements_of_path <- function(x) {
  if (is.na(x)) {
    x
  } else {
    file.path(
      basename(dirname(x)),
      basename(x)
    )
  }
}
poseidon-framework/anno2janno documentation built on March 15, 2024, 4:30 a.m.