# HG changeset patch # User proteore # Date 1521816437 14400 # Node ID 715002a394ec5c7e6a7f1986ba4ab39031105eb6 # Parent ed226f0e5625c2fad0c46489302e10555406b7be planemo upload commit b36435833bf54f90f62cc240f2cda1c889161b23-dirty diff -r ed226f0e5625 -r 715002a394ec goprofiles.R --- a/goprofiles.R Wed Mar 14 12:51:53 2018 -0400 +++ b/goprofiles.R Fri Mar 23 10:47:17 2018 -0400 @@ -2,20 +2,22 @@ library(org.Hs.eg.db) library(goProfiles) -# Read file and return file content as data.frame? +# Read file and return file content as data.frame readfile = function(filename, header) { if (header == "true") { - # Read only the first line of the files as data (without headers): - headers <- read.table(filename, nrows = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE) - #Read the data of the files (skipping the first row): - file <- read.table(filename, skip = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE) + # Read only first line of the file as header: + headers <- read.table(filename, nrows = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE, quote = "") + #Read the data of the files (skipping the first row) + file <- read.table(filename, skip = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE, quote = "") # Remove empty rows - file <- file[!apply(is.na(file) | file == "", 1, all),] - #And assign the headers of step two to the data: + file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE] + #And assign the header to the data names(file) <- headers } else { - file <- read.table(filename, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE) + file <- read.table(filename, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE, quote = "") + # Remove empty rows + file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE] } return(file) } @@ -175,7 +177,7 @@ input_type = args$input_type if (input_type == "text") { - input = strsplit(args$input, " ")[[1]] + input = strsplit(args$input, "[ \t\n]+")[[1]] } else if (input_type == "file") { filename = args$input diff -r ed226f0e5625 -r 715002a394ec goprofiles.xml --- a/goprofiles.xml Wed Mar 14 12:51:53 2018 -0400 +++ b/goprofiles.xml Fri Mar 23 10:47:17 2018 -0400 @@ -44,7 +44,7 @@ - +