diff probmetab.r @ 3:abcfa1648b66 draft

planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
author lecorguille
date Fri, 07 Apr 2017 07:14:12 -0400
parents e13ec2c3fabe
children
line wrap: on
line diff
--- a/probmetab.r	Mon Jul 04 11:58:10 2016 -0400
+++ b/probmetab.r	Fri Apr 07 07:14:12 2017 -0400
@@ -4,7 +4,7 @@
 
 
 # ----- LOG -----
-log_file=file("probmetab.log", open = "wt")
+log_file=file("log.txt", open = "wt")
 sink(log_file)
 sink(log_file, type = "out")
 
@@ -12,8 +12,8 @@
 cat("\tPACKAGE INFO\n")
 pkgs=c("parallel","BiocGenerics", "Biobase", "Rcpp", "mzR", "igraph", "xcms","snow","CAMERA","batch","ProbMetab")
 for(p in pkgs) {
-	suppressWarnings( suppressPackageStartupMessages( stopifnot( library(p, quietly=TRUE, logical.return=TRUE, character.only=TRUE))))
-	cat(p,"\t",as.character(packageVersion(p)),"\n",sep="")
+    suppressWarnings( suppressPackageStartupMessages( stopifnot( library(p, quietly=TRUE, logical.return=TRUE, character.only=TRUE))))
+    cat(p,"\t",as.character(packageVersion(p)),"\n",sep="")
 }
 
 source_local <- function(fname){
@@ -21,9 +21,14 @@
     base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
     source(paste(base_dir, fname, sep="/"))
 }
+
+options(bitmapType='cairo')
+
 cat("\n\n")
+
+
 # ----- ARGUMENTS -----
-cat("\tARGUMENTS INFO\n") 
+cat("\tARGUMENTS INFO\n")
 listArguments = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects
 write.table(as.matrix(listArguments), col.names=F, quote=F, sep='\t')
 
@@ -35,68 +40,59 @@
 # ----- INFILE PROCESSING -----
 
 if(listArguments[["mode_acquisition"]]=="one") {
-	load(listArguments[["xa"]])
-    
-    if (!is.null(listArguments[["zipfile"]])){
-        zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL
-    }
-	
-    #Unzip the chromatograms file for plotting EIC pour the HTML file
-	if(exists("zipfile"))
-	{
-		if (zipfile!=""){
-			directory=unzip(zipfile)
-		}
-	}	
-	if (!exists("xa")) {
-		xa=xsAnnotate_object
-	}
-	source_local("lib.r")
-	if (!exists("variableMetadata")) variableMetadata= getVariableMetadata(xa);
-	
+    load(listArguments[["image"]])
+    cat("\t\tXA OBJECT INFO\n")
+    print(xa)
+
+    source_local("lib.r")
+    if (!exists("zipfile")) zipfile=NULL
+    if (!exists("singlefile")) singlefile=NULL
+    rawFilePath = getRawfilePathFromArguments(singlefile, zipfile, listArguments)
+    zipfile = rawFilePath$zipfile
+    singlefile = rawFilePath$singlefile
+    retrieveRawfileInTheWorkingDirectory(singlefile, zipfile)
+
+    if (!exists("variableMetadata")) variableMetadata= getVariableMetadata(xa);
+
 } else if(listArguments[["inputs_mode"]]=="two"){
-	load(listArguments[["image_pos"]])
-    
-    if (!is.null(listArguments[["zipfile"]])){
-        zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL
-    }
-    
-	#Unzip the chromatograms file for plotting EIC pour the HTML file
-	if(exists("zipfile")) {
-		if (zipfile!=""){
-			directory=unzip(zipfile)
-		}
-	}
-	if (!exists("xa")) {
-		xa=xsAnnotate_object
-	}
-	xaP=xa
-	source_local("lib.r")	
-	if (!exists("variableMetadata")) variableMetadataP= getVariableMetadata(xa)
-	else variableMetadataP=variableMetadata
+
+    # POSITIVE
+    load(listArguments[["image_pos"]])
 
+    if (!exists("xa")) xaP=xsAnnotate_object
+    else xaP=xa
+    cat("\t\tXA-POSITIVE OBJECT INFO\n")
+    print(xaP)
+
+    if (!exists("variableMetadata")) variableMetadataP = getVariableMetadata(xa)
+    else variableMetadataP = variableMetadata
 
-	load(listArguments[["image_neg"]])
-    
-    if (!is.null(listArguments[["zipfile"]])){
-        zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL
-    }
-    
-	#Unzip the chromatograms file for plotting EIC pour the HTML file
-	if(exists("zipfile")) {
-		
-	 	if (zipfile!=""){
-			directory=unzip(zipfile)
-		}
-	}
-	if (!exists("xa")) {
-		xa=xsAnnotate_object
-	}
-	xaN=xa
-	source_local("lib.r")
-	
-	if (!exists("variableMetadata")) variableMetadataN= getVariableMetadata(xa)
-	else variableMetadataN=variableMetadata
+    source_local("lib.r")
+    if (!exists("zipfile")) zipfile=NULL
+    if (!exists("singlefile")) singlefile=NULL
+    rawFilePath = getRawfilePathFromArguments(singlefile, zipfile, listArguments)
+    zipfilePos = rawFilePath$zipfile
+    singlefilePos = rawFilePath$singlefile
+    retrieveRawfileInTheWorkingDirectory(singlefilePos, zipfilePos)
+
+    # NEGATIVE
+    load(listArguments[["image_neg"]])
+
+    if (!exists("xa"))  xaN=xsAnnotate_object
+    else xaN=xa
+    cat("\t\tXA-NEGATIVE OBJECT INFO\n")
+    print(xaP)
+
+    if (!exists("variableMetadata")) variableMetadataN = getVariableMetadata(xa)
+    else variableMetadataN = variableMetadata
+
+    source_local("lib.r")
+    if (!exists("zipfile")) zipfile=NULL
+    if (!exists("singlefile")) singlefile=NULL
+    rawFilePath = getRawfilePathFromArguments(singlefile, zipfile, listArguments)
+    zipfileNeg = rawFilePath$zipfile
+    singlefileNeg = rawFilePath$singlefile
+    retrieveRawfileInTheWorkingDirectory(singlefileNeg, zipfileNeg)
 }
 
 #Import the different functions
@@ -107,13 +103,12 @@
 cat("\tMAIN PROCESSING INFO\n")
 
 if(listArguments[["mode_acquisition"]]=="one") {
-	results=probmetab(xa=xa, variableMetadata=variableMetadata,listArguments=listArguments)
+    results=probmetab(xa=xa, variableMetadata=variableMetadata,listArguments=listArguments)
 } else if(listArguments[["inputs_mode"]]=="two"){
-	results=probmetab(xaP=xaP, xaN=xaN,variableMetadataP=variableMetadataP, variableMetadataN=variableMetadataN, listArguments=listArguments)
+    results=probmetab(xaP=xaP, xaN=xaN,variableMetadataP=variableMetadataP, variableMetadataN=variableMetadataN, listArguments=listArguments)
 }
 #delete the parameters to avoid the passage to the next tool in .RData image
 #rm(listArguments)
 cat("\tDONE\n")
 #saving R data in .Rdata file to save the variables used in the present tool
 #save.image(paste("probmetab","RData",sep="."))
-