diff xcms.r @ 6:60f6c208ca16 draft

planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
author lecorguille
date Thu, 07 Apr 2016 15:02:32 -0400
parents b9a87af62223
children f28041d2180a
line wrap: on
line diff
--- a/xcms.r	Wed Apr 06 03:22:15 2016 -0400
+++ b/xcms.r	Thu Apr 07 15:02:32 2016 -0400
@@ -77,7 +77,7 @@
 
 
 
-if (thefunction == "xcmsSet" || thefunction == "retcor") {
+if (thefunction %in% c("xcmsSet","retcor")) {
   ticspdf = listArguments[["ticspdf"]]; listArguments[["ticspdf"]]=NULL
   bicspdf = listArguments[["bicspdf"]]; listArguments[["bicspdf"]]=NULL
 }
@@ -100,7 +100,7 @@
 }
 
 # We unzip automatically the chromatograms from the zip files.
-if (thefunction == "xcmsSet" || thefunction == "retcor" || thefunction == "fillPeaks")  {
+if (thefunction %in% c("xcmsSet","retcor","fillPeaks"))  {
   if(exists("zipfile") && (zipfile!="")) {
     if(!file.exists(zipfile)){
       error_message=paste("Cannot access the Zip file:",zipfile,". Please, contact your administrator ... if you have one!")
@@ -111,15 +111,19 @@
     #list all file in the zip file
     #zip_files=unzip(zipfile,list=T)[,"Name"]
 
-    #get the directory name
-    filesInZIp=unzip(zipfile, list=T); 
-    directories=unique(unlist(lapply(strsplit(filesInZIp$Name,"/"), function(x) x[1])));
-    directories=directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir]
-    if (length(directories) == 1) directory=directories else directory=".";
 
     #unzip
     suppressWarnings(unzip(zipfile, unzip="unzip"))
 
+    #get the directory name
+    filesInZip=unzip(zipfile, list=T); 
+    directories=unique(unlist(lapply(strsplit(filesInZip$Name,"/"), function(x) x[1])));
+    directories=directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir]
+    directory = "."
+    if (length(directories) == 1) directory = directories
+    
+    cat("files_root_directory\t",directory,"\n")
+
     # 
     md5sumList=list("origin"=getMd5sum(directory))
 
@@ -190,11 +194,11 @@
 
 dev.off() #dev.new(file="Rplots.pdf", width=16, height=12)
 
-if (thefunction == "xcmsSet") {
+if (thefunction  == "xcmsSet") {
 
   #transform the files absolute pathways into relative pathways
-  xset@filepaths<-sub("^.*/database/job_working_directory/[0123456789]+/[0123456789]+/" ,"", xset@filepaths)
-  xset@filepaths<-sub("^.*/database/jobs/[0123456789]+/[0123456789]+/" ,"", xset@filepaths)
+  xset@filepaths<-sub(paste(getwd(),"/",sep="") ,"", xset@filepaths)
+
   if(exists("zipfile") && (zipfile!="")) {
     
     #Modify the samples names (erase the path)