Skip to contents

This function processes and validates a user-provided reference CSV file. The process includes reading the file, preprocessing it to remove empty rows or columns, and then validating and formatting based on the given reference type and action. If the file doesn't meet the specific requirements or if any validation rules are violated, appropriate errors or warnings will be raised.

Usage

process_reference_csv(
  user_csv,
  user_action,
  reference_type,
  database = Sys.getenv("SDB_PATH"),
  config_yml = Sys.getenv("SDB_CONFIG")
)

Arguments

user_csv

The path to the user's reference CSV file. This will be read into a data frame.

user_action

A character string indicating the action the user is taking (e.g., 'upload').

reference_type

A character string specifying the type of references in the user CSV. Valid types are 'compositions' of 'strains'.

database

A character string indicating the path to the SQLite database used for validation checks. Defaults to the system environment variable 'SDB_PATH'.

config_yml

A character string indicating the path to a configuration YAML file. Defaults to the system environment variable 'SDB_CONFIG'.

Value

A processed and validated reference CSV as a data frame.

Examples

if (FALSE) { # \dontrun{
# Provide the path to the user CSV file and action details
user_file_path <- "path/to/user/reference_file.csv"
action <- "upload"
type <- "compositions"

# Process and validate the user CSV
processed_data <- process_reference_csv(user_file_path, action, type)
} # }