# HG changeset patch # User proteore # Date 1544091941 18000 # Node ID 9525c7c2d5d61b471091043e05548068265cd47d # Parent 2fc914ab92f5d48ed4b83b64b06359d754e63d82 planemo upload commit 78ad61e52c2bf8c5ffada89a8eed429a332eb40b-dirty diff -r 2fc914ab92f5 -r 9525c7c2d5d6 protein_features.R --- a/protein_features.R Tue Dec 04 05:48:58 2018 -0500 +++ b/protein_features.R Thu Dec 06 05:25:41 2018 -0500 @@ -101,12 +101,19 @@ #create new lines if there's more than one id per cell in the columns in order to have only one id per line one_id_one_line <-function(tab,ncol){ - tab[,ncol] = sapply(tab[,ncol],function(x) gsub("[[:blank:]]","",x)) - header=colnames(tab) - res=as.data.frame(matrix(ncol=ncol(tab),nrow=0)) - for (i in 1:nrow(tab) ) { - lines = split_ids_per_line(tab[i,],ncol) - res = rbind(res,lines) + if (ncol(tab)>1){ + + tab[,ncol] = sapply(tab[,ncol],function(x) gsub("[[:blank:]]","",x)) + header=colnames(tab) + res=as.data.frame(matrix(ncol=ncol(tab),nrow=0)) + for (i in 1:nrow(tab) ) { + lines = split_ids_per_line(tab[i,],ncol) + res = rbind(res,lines) + } + }else { + res = unlist(sapply(tab[,1],function(x) strsplit(x,";")),use.names = F) + res = data.frame(res[which(!is.na(res[res!=""]))],stringsAsFactors = F) + colnames(res)=colnames(tab) } return(res) }