From ebd7bd4c1dfdf4e4c8887b959568b152f20fa91d Mon Sep 17 00:00:00 2001 From: Ethan Bass Date: Sun, 30 Jul 2023 11:27:12 -0400 Subject: [PATCH] style: fixed whitespace, removed zombie code --- R/aston_parsers.R | 22 ++++++++++------------ R/read_cdf.R | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/R/aston_parsers.R b/R/aston_parsers.R index 35e44ad..8a59dd4 100644 --- a/R/aston_parsers.R +++ b/R/aston_parsers.R @@ -1,6 +1,7 @@ #' Converter for Agilent MassHunter UV files #' -#' Converts a single chromatogram from MassHunter \code{.sp} format to R \code{data.frame}. +#' Converts a single chromatogram from MassHunter \code{.sp} format to R +#' \code{data.frame}. #' #' Uses the [Aston](https://github.com/bovee/aston) file parser. #' @@ -40,7 +41,8 @@ sp_converter <- function(file, format_out = c("matrix", "data.frame"), #' Converter for Agilent ChemStation UV files #' -#' Converts a single chromatogram from ChemStation \code{.uv} format to R \code{data.frame}. +#' Converts a single chromatogram from ChemStation \code{.uv} format to R +#' \code{data.frame}. #' #' Uses the [Aston](https://github.com/bovee/aston) file parser. #' @@ -74,10 +76,9 @@ uv_converter <- function(file, format_out = c("matrix","data.frame"), } if (correction){ # multiply by empirical correction value - x <- apply(x,2,function(xx)xx*0.9536743164062551070259132757200859487056732177734375) + correction_value <- 0.9536743164062551070259132757200859487056732177734375 + x <- apply(x,2,function(xx)xx*correction_value) } - # correct column order - # x <- lapply(x, function(xx) xx[,order(as.numeric(colnames(xx)))]) if (read_metadata){ meta <- read_chemstation_metadata(file) x <- attach_metadata(x, meta, format_in = "chemstation_uv", @@ -129,24 +130,21 @@ trace_converter <- function(file, format_out = c("matrix", "data.frame"), #' @author Ethan Bass #' @import reticulate #' @export -configure_aston <- function(return_boolean=FALSE){ +configure_aston <- function(return_boolean = FALSE){ install <- FALSE - # path <- miniconda_path() if (!dir.exists(miniconda_path())){ install <- readline("It is recommended to install miniconda in your R library to use Aston parsers. Install miniconda now? (y/n)") if (install %in% c('y', "Y", "YES", "yes", "Yes")){ install_miniconda() } - } # else{ - # envs <- conda_list() - # use_miniconda(envs[grep("r-reticulate", envs$name)[1],2]) - # } + } env <- reticulate::configure_environment("chromConverter") if (!env){ reqs <- c("pandas","scipy","numpy","aston") reqs_available <- sapply(reqs, reticulate::py_module_available) if (!all(reqs_available)){ - conda_install(envname = "chromConverter", reqs[which(!reqs_available)], pip = TRUE) + conda_install(envname = "chromConverter", reqs[which(!reqs_available)], + pip = TRUE) } } assign_trace_file() diff --git a/R/read_cdf.R b/R/read_cdf.R index 276084e..85633be 100644 --- a/R/read_cdf.R +++ b/R/read_cdf.R @@ -12,7 +12,7 @@ #' @author Ethan Bass #' @export -read_cdf <- function(file, format_out = c("matrix","data.frame"), +read_cdf <- function(file, format_out = c("matrix", "data.frame"), data_format = c("wide","long"), what = "chromatogram", read_metadata = TRUE){ check_for_pkg("ncdf4")