comparison protein_features.R @ 2:9525c7c2d5d6 draft

planemo upload commit 78ad61e52c2bf8c5ffada89a8eed429a332eb40b-dirty
author proteore
date Thu, 06 Dec 2018 05:25:41 -0500
parents 2fc914ab92f5
children 7746af0f8209
comparison
equal deleted inserted replaced
1:2fc914ab92f5 2:9525c7c2d5d6
99 } 99 }
100 100
101 #create new lines if there's more than one id per cell in the columns in order to have only one id per line 101 #create new lines if there's more than one id per cell in the columns in order to have only one id per line
102 one_id_one_line <-function(tab,ncol){ 102 one_id_one_line <-function(tab,ncol){
103 103
104 tab[,ncol] = sapply(tab[,ncol],function(x) gsub("[[:blank:]]","",x)) 104 if (ncol(tab)>1){
105 header=colnames(tab) 105
106 res=as.data.frame(matrix(ncol=ncol(tab),nrow=0)) 106 tab[,ncol] = sapply(tab[,ncol],function(x) gsub("[[:blank:]]","",x))
107 for (i in 1:nrow(tab) ) { 107 header=colnames(tab)
108 lines = split_ids_per_line(tab[i,],ncol) 108 res=as.data.frame(matrix(ncol=ncol(tab),nrow=0))
109 res = rbind(res,lines) 109 for (i in 1:nrow(tab) ) {
110 lines = split_ids_per_line(tab[i,],ncol)
111 res = rbind(res,lines)
112 }
113 }else {
114 res = unlist(sapply(tab[,1],function(x) strsplit(x,";")),use.names = F)
115 res = data.frame(res[which(!is.na(res[res!=""]))],stringsAsFactors = F)
116 colnames(res)=colnames(tab)
110 } 117 }
111 return(res) 118 return(res)
112 } 119 }
113 120
114 # Get information from neXtProt 121 # Get information from neXtProt