diff --git a/R/checkIfFile.R b/R/checkIfFile.R index 0f14aef..7ebf4d5 100644 --- a/R/checkIfFile.R +++ b/R/checkIfFile.R @@ -4,35 +4,29 @@ # 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)) { - 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) - } - + x <- 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: