diff CAMERA.r @ 4:9a1a72ee9418 draft

planemo upload commit 2761472c8afc41d54cecd54cabd1c5a5713514a3-dirty
author lecorguille
date Mon, 25 Apr 2016 09:25:31 -0400
parents 2591056df814
children 972152941964
line wrap: on
line diff
--- a/CAMERA.r	Tue Apr 12 04:14:10 2016 -0400
+++ b/CAMERA.r	Mon Apr 25 09:25:31 2016 -0400
@@ -6,8 +6,10 @@
 # ----- PACKAGE -----
 cat("\tPACKAGE INFO\n")
 
+setRepositories(graphics=F, ind=31)
+
 #pkgs=c("xcms","batch")
-pkgs=c("parallel","BiocGenerics", "Biobase", "Rcpp", "mzR", "tcltk","igraph", "xcms","snow","CAMERA","multtest","batch")
+pkgs=c("parallel","BiocGenerics", "Biobase", "Rcpp", "mzR", "xcms","snow","igraph","CAMERA","multtest","batch")
 for(p in pkgs) {
   suppressPackageStartupMessages(suppressWarnings(library(p, quietly=TRUE, logical.return=TRUE, character.only=TRUE)))
   cat(p,"\t",as.character(packageVersion(p)),"\n",sep="")
@@ -37,7 +39,8 @@
 
 if (listArguments[["xfunction"]] %in% c("combinexsAnnos")) {
   load(listArguments[["image_pos"]])
-  xaP=xa  
+  xaP=xa
+  listOFlistArgumentsP=listOFlistArguments
   if (exists("xsAnnotate_object")) xaP=xsAnnotate_object
   
   diffrepP=NULL
@@ -45,6 +48,7 @@
 
   load(listArguments[["image_neg"]])
   xaN=xa
+  listOFlistArgumentsN=listOFlistArguments
   if (exists("xsAnnotate_object")) xaN=xsAnnotate_object
 
   diffrepN=NULL
@@ -94,14 +98,39 @@
 #Import the different functions
 source_local("lib.r")
 
+#necessary to unzip .zip file uploaded to Galaxy
+#thanks to .zip file it's possible to upload many file as the same time conserving the tree hierarchy of directories
+
+
+if (!is.null(listArguments[["zipfile"]])){
+  zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL
+}
+
 # We unzip automatically the chromatograms from the zip files.
-if (thefunction == "annotatediff")  {
+if (thefunction %in% c("annotatediff"))  {
   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!")
+      print(error_message)
+      stop(error_message)
+    }
+
+    #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")
   }
 }
 
 
+
 #addition of xset object to the list of arguments in the first position
 if (exists("xset") != 0){
   listArguments=append(list(xset), listArguments)
@@ -131,7 +160,7 @@
 }
 
 if (thefunction %in% c("combinexsAnnos")) {
-  cAnnot=combinexsAnnos_function(xaP=xaP,xaN=xaN,diffrepP=diffrepP,diffrepN=diffrepN,convert_param=listArguments[["convert_param"]],pos=listArguments[["pos"]],tol=listArguments[["tol"]],ruleset=listArguments[["ruleset"]],keep_meta=listArguments[["keep_meta"]],variableMetadataOutput=variableMetadataOutput)
+  cAnnot=combinexsAnnos_function(xaP=xaP,xaN=xaN,listOFlistArgumentsP=listOFlistArgumentsP,listOFlistArgumentsN=listOFlistArgumentsN,diffrepP=diffrepP,diffrepN=diffrepN,convert_param=listArguments[["convert_param"]],pos=listArguments[["pos"]],tol=listArguments[["tol"]],ruleset=listArguments[["ruleset"]],keep_meta=listArguments[["keep_meta"]],variableMetadataOutput=variableMetadataOutput)
 }
 
 dev.off()