R/tlu_setup_dir.R

Defines functions tlu_setup_dir

Documented in tlu_setup_dir

#' Copy MK9 data and setup directory
#' 
#' Setup directory and retrieve data for processing MK9 data.
#' 
#' @param channel Oracle connection as an RODBC connection object.
#' @param survey RACE survey code as a character vector.
#' @param light_data_root Filepath to the data source
#' @param ... Additional arguments passed to trawllight:::tlu_prep_dir_list. Used to remove special projects directories from 2021 tag comparison project (Haehn, Laman, Rohan).
#' @export

tlu_setup_dir <- function(channel = NULL, survey, light_data_root = "G:/RACE_LIGHT/LightData/Data", ...) {
  
  if(!(survey %in% c("BS", "NBS", "GOA", "AI"))) {
    stop(paste0("survey selection, ", survey, " invalid. Must be 'BS', 'NBS', 'GOA', or 'AI'."))
  }
  
  channel <- trawllight:::get_connected(channel = channel, schema = "AFSC")
  
  if(!dir.exists(here::here("data"))) {
    dir.create(here::here("data"))
  } else {
    warning(paste0("'data' directory already exists and was not overwritten."))
  }
  
  if(!dir.exists(here::here("output"))) {
    dir.create(here::here("output"))
  } else {
    warning(paste0("'output' directory already exists and was not overwritten."))
  }
  
  if(!dir.exists(here::here("imports"))) {
    dir.create(here::here("imports"))
  } else {
    warning(paste0("'imports' directory already exists and was not overwritten."))
  }
  
  trawllight:::tlu_prep_haul_data(channel = channel,
                                 survey = survey)
  
  trawllight:::tlu_prep_dir_list(survey = survey,
                                light_data_root = light_data_root, ...)
  
}
sean-rohan/trawllight documentation built on Jan. 13, 2023, 10:43 p.m.