changeset 2:9525c7c2d5d6 draft

planemo upload commit 78ad61e52c2bf8c5ffada89a8eed429a332eb40b-dirty
author proteore
date Thu, 06 Dec 2018 05:25:41 -0500
parents 2fc914ab92f5
children 7746af0f8209
files protein_features.R
diffstat 1 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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)
 }