comparison add_protein_features.R @ 5:bb4a5f1b415f draft

planemo upload commit f7974932f7ca782b9a5a8a092f84a0bb0f965e64-dirty
author proteore
date Mon, 11 Mar 2019 04:39:31 -0400
parents 759850de6ed2
children aca66c3b8fbb
comparison
equal deleted inserted replaced
4:759850de6ed2 5:bb4a5f1b415f
1 # Read file and return file content as data.frame 1 # Read file and return file content as data.frame
2 read_file <- function(path,header){ 2 read_file <- function(path,header){
3 file <- try(read.table(path,header=header, sep="\t",stringsAsFactors = FALSE, quote="", check.names = F),silent=TRUE) 3 file <- try(read.csv(path,header=header, sep="\t",stringsAsFactors = FALSE, quote="", check.names = F),silent=TRUE)
4 if (inherits(file,"try-error")){ 4 if (inherits(file,"try-error")){
5 stop("File not found !") 5 stop("File not found !")
6 }else{ 6 }else{
7 file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE] 7 file <- file[!apply(is.na(file) | file == "", 1, all), , drop=FALSE]
8 return(file) 8 return(file)
134 134
135 protein_features = function() { 135 protein_features = function() {
136 136
137 args <- get_args() 137 args <- get_args()
138 138
139 #save(args,file="/home/dchristiany/proteore_project/ProteoRE/tools/add_human_protein_features/args.rda") 139 #save(args,file="/home/dchristiany/proteore_project/ProteoRE/tools/add_protein_features/args.rda")
140 #load("/home/dchristiany/proteore_project/ProteoRE/tools/add_human_protein_features/args.rda") 140 #load("/home/dchristiany/proteore_project/ProteoRE/tools/add_protein_features/args.rda")
141 141
142 #setting variables 142 #setting variables
143 inputtype = args$inputtype 143 inputtype = args$inputtype
144 if (inputtype == "copy_paste") { 144 if (inputtype == "copy_paste") {
145 input = get_list_from_cp(args$input) 145 input = get_list_from_cp(args$input)
192 } else { 192 } else {
193 res <- get_nextprot_info(nextprot,NextprotID,pc_features,localization,diseases_info) 193 res <- get_nextprot_info(nextprot,NextprotID,pc_features,localization,diseases_info)
194 res = res[!duplicated(res$NextprotID),] 194 res = res[!duplicated(res$NextprotID),]
195 output_content = merge(file, res,by.x=ncol,by.y="NextprotID",incomparables = NA,all.x=T) 195 output_content = merge(file, res,by.x=ncol,by.y="NextprotID",incomparables = NA,all.x=T)
196 output_content = order_columns(output_content,ncol,id_type,file) 196 output_content = order_columns(output_content,ncol,id_type,file)
197 output_content = output_content[,-which(colnames(output_content)=="NextprotID")] #remove nextprotID column
197 output_content <- as.data.frame(apply(output_content, c(1,2), function(x) gsub("^$|^ $", NA, x))) #convert "" et " " to NA 198 output_content <- as.data.frame(apply(output_content, c(1,2), function(x) gsub("^$|^ $", NA, x))) #convert "" et " " to NA
198 write.table(output_content, output, row.names = FALSE, sep = "\t", quote = FALSE) 199 write.table(output_content, output, row.names = FALSE, sep = "\t", quote = FALSE)
199 } 200 }
200 201
201 } 202 }