comparison id_converter_UniProt.R @ 4:134949593a3b draft

planemo upload commit 4af7ac25de19ca10b1654820e909c647a2d337b2-dirty
author proteore
date Mon, 19 Mar 2018 09:58:17 -0400
parents f2d0b13d9615
children 0584344186eb
comparison
equal deleted inserted replaced
3:72860740f65f 4:134949593a3b
1 # Read file and return file content as data.frame 1 # Read file and return file content as data.frame
2 readfile = function(filename, header) { 2 readfile = function(filename, header) {
3 if (header == "true") { 3 if (header == "true") {
4 # Read only first line of the file as header: 4 # Read only first line of the file as header:
5 headers <- read.table(filename, nrows = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE) 5 headers <- read.table(filename, nrows = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE, quote = "")
6 #Read the data of the files (skipping the first row) 6 #Read the data of the files (skipping the first row)
7 file <- read.table(filename, skip = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE) 7 file <- read.table(filename, skip = 1, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE, quote = "")
8 # Remove empty rows 8 # Remove empty rows
9 file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE] 9 file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE]
10 #And assign the header to the data 10 #And assign the header to the data
11 names(file) <- headers 11 names(file) <- headers
12 } 12 }
13 else { 13 else {
14 file <- read.table(filename, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE) 14 file <- read.table(filename, header = FALSE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings=c("", "NA"), blank.lines.skip = TRUE, quote = "")
15 # Remove empty rows 15 # Remove empty rows
16 file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE] 16 file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE]
17 } 17 }
18 return(file) 18 return(file)
19 } 19 }
52 options = strsplit(args[4], ",")[[1]] 52 options = strsplit(args[4], ",")[[1]]
53 output = args[5] 53 output = args[5]
54 human_id_mapping_file = args[6] 54 human_id_mapping_file = args[6]
55 55
56 # Extract ID maps 56 # Extract ID maps
57 human_id_map = read.table(human_id_mapping_file, header = TRUE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings = "") 57 human_id_map = read.table(human_id_mapping_file, header = TRUE, sep = "\t", stringsAsFactors = FALSE, fill = TRUE, na.strings = "", quote = "")
58 58
59 # Extract input IDs 59 # Extract input IDs
60 if (list_id_input_type == "list") { 60 if (list_id_input_type == "list") {
61 list_id = strsplit(args[2], " ")[[1]] 61 list_id = strsplit(args[2], " ")[[1]]
62 # Remove isoform accession number (e.g. "-2") 62 # Remove isoform accession number (e.g. "-2")