Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions R/checkIfFile.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion R/protein2SiteConversion.R
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down