From fa1584704200bdd0592296e0ca37ca2cbff6982c Mon Sep 17 00:00:00 2001 From: Ben Polacco Date: Thu, 9 Apr 2020 09:30:47 -0700 Subject: [PATCH 1/2] dont_check_names used for data.frame and data.table evidence_file --- R/checkIfFile.R | 16 +++++----------- R/protein2SiteConversion.R | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/R/checkIfFile.R b/R/checkIfFile.R index 0f14aef..5dc46d7 100644 --- a/R/checkIfFile.R +++ b/R/checkIfFile.R @@ -16,23 +16,17 @@ is.evidence = FALSE) { # check if already a data.frame or data.table if (is.data.table(input_file)) { - x <- data.table(input_file) + x <- data.table(input_file, check.names = !dont_check_names) } else if (is.data.frame(input_file)) { - x <- data.frame(input_file) + x <- data.frame(input_file, check.names = !dont_check_names) } else if (is.vector(input_file)){ if(length(input_file) == 1){ if(!file.exists(input_file)){ stop("The file ", input_file, " does not exist! ") }else{ - if(dont_check_names){ - x <- read.delim(input_file, - stringsAsFactors = FALSE) - }else{ - x <- read.delim(input_file, - stringsAsFactors = FALSE, - check.names = FALSE) - } - + read.delim(input_file, + stringsAsFactors = FALSE, + check.names = !dont_check_names) } }else{ stop("The input object is not valid") diff --git a/R/protein2SiteConversion.R b/R/protein2SiteConversion.R index a1277ed..4c9e040 100644 --- a/R/protein2SiteConversion.R +++ b/R/protein2SiteConversion.R @@ -133,7 +133,7 @@ then make the argument 'overwrite_evidence = TRUE'") ## map mod sites in data to index if(verbose) message("--- OPENING EVIDENCE FILE ") ## read in maxq. data - maxq_data <- .artms_checkIfFile(evidence_file, dont_check_names = FALSE) + maxq_data <- .artms_checkIfFile(evidence_file, dont_check_names = TRUE) maxq_data <- as.data.table(maxq_data) # Check maxquant version: From 0d786868f8b18dfe966c6dc16f7e115fbf2d7f81 Mon Sep 17 00:00:00 2001 From: Ben Polacco Date: Thu, 9 Apr 2020 12:02:49 -0700 Subject: [PATCH 2/2] fix dont_check_names default and docstring; add a dropped x <- --- R/checkIfFile.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/R/checkIfFile.R b/R/checkIfFile.R index 5dc46d7..7ebf4d5 100644 --- a/R/checkIfFile.R +++ b/R/checkIfFile.R @@ -4,15 +4,15 @@ # either a path to a data file or a data object in data.frame or data.table # form. # @param input_file (object or data.frame) The filepath/object to be checked. -# @param dont_check_names if TRUE (default) names are not checked, otherwise -# names will be checked +# @param dont_check_names if TRUE names are not checked, otherwise +# names will be checked (default) # @param is.evidence (logical) Whether or not the file to be read in is an # evidence file. This will assign proper classes to the evidence file # when being read in. # @return An R data object # @keywords internal, file, evidence, input .artms_checkIfFile <- function(input_file, - dont_check_names = TRUE, + dont_check_names = FALSE, is.evidence = FALSE) { # check if already a data.frame or data.table if (is.data.table(input_file)) { @@ -24,9 +24,9 @@ if(!file.exists(input_file)){ stop("The file ", input_file, " does not exist! ") }else{ - read.delim(input_file, - stringsAsFactors = FALSE, - check.names = !dont_check_names) + x <- read.delim(input_file, + stringsAsFactors = FALSE, + check.names = !dont_check_names) } }else{ stop("The input object is not valid")