comparison probmetab.r @ 0:71047cbb3e6c draft default tip

planemo upload commit 858f2560108824c0c4d6e9f700d1690308bb13ad
author lecorguille
date Tue, 24 May 2016 11:17:59 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:71047cbb3e6c
1 #!/usr/local/public/bin/Rscript --vanilla --slave --no-site-file
2 # probmetab.r version="1.0.0"
3 # Author: Misharl Monsoor ABIMS TEAM mmonsoor@sb-roscoff.fr
4
5
6 # ----- LOG -----
7 log_file=file("probmetab.log", open = "wt")
8 sink(log_file)
9 sink(log_file, type = "out")
10
11 # ----- PACKAGE -----
12 cat("\tPACKAGE INFO\n")
13 pkgs=c("parallel","BiocGenerics", "Biobase", "Rcpp", "mzR", "igraph", "xcms","snow","CAMERA","batch","ProbMetab")
14 for(p in pkgs) {
15 suppressWarnings( suppressPackageStartupMessages( stopifnot( library(p, quietly=TRUE, logical.return=TRUE, character.only=TRUE))))
16 cat(p,"\t",as.character(packageVersion(p)),"\n",sep="")
17 }
18
19 source_local <- function(fname){
20 argv <- commandArgs(trailingOnly = FALSE)
21 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
22 source(paste(base_dir, fname, sep="/"))
23 }
24 cat("\n\n")
25 # ----- ARGUMENTS -----
26 cat("\tARGUMENTS INFO\n")
27 listArguments = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects
28 write.table(as.matrix(listArguments), col.names=F, quote=F, sep='\t')
29
30
31 # ----- PROCESSING INFILE -----
32 cat("\tINFILE PROCESSING INFO\n")
33
34 # ----- INFILE PROCESSING -----
35
36 if(listArguments[["mode_acquisition"]]=="one") {
37 load(listArguments[["xa"]])
38 #Unzip the chromatograms file for plotting EIC pour the HTML file
39 if(exists("zipfile"))
40 {
41 if (zipfile!=""){
42 directory=unzip(zipfile)
43 }
44 }
45 if (!exists("xa")) {
46 xa=xsAnnotate_object
47 }
48 source_local("lib.r")
49 if (!exists("variableMetadata")) variableMetadata= getVariableMetadata(xa);
50
51 } else if(listArguments[["inputs_mode"]]=="two"){
52 load(listArguments[["image_pos"]])
53 #Unzip the chromatograms file for plotting EIC pour the HTML file
54 if(exists("zipfile")) {
55 if (zipfile!=""){
56 directory=unzip(zipfile)
57 }
58 }
59 if (!exists("xa")) {
60 xa=xsAnnotate_object
61 }
62 xaP=xa
63 source_local("lib.r")
64 if (!exists("variableMetadata")) variableMetadataP= getVariableMetadata(xa)
65 else variableMetadataP=variableMetadata
66
67
68 load(listArguments[["image_neg"]])
69 #Unzip the chromatograms file for plotting EIC pour the HTML file
70 if(exists("zipfile")) {
71
72 if (zipfile!=""){
73 directory=unzip(zipfile)
74 }
75 }
76 if (!exists("xa")) {
77 xa=xsAnnotate_object
78 }
79 xaN=xa
80 source_local("lib.r")
81
82 if (!exists("variableMetadata")) variableMetadataN= getVariableMetadata(xa)
83 else variableMetadataN=variableMetadata
84 }
85
86 print(directory)
87 print(dir(directory))
88
89 #Import the different functions
90 source_local("lib.r")
91 source_local("export.class.table-color-graph.R")
92
93 # ----- PROCESSING INFO -----
94 cat("\tMAIN PROCESSING INFO\n")
95
96 if(listArguments[["mode_acquisition"]]=="one") {
97 results=probmetab(xa=xa, variableMetadata=variableMetadata,listArguments=listArguments)
98 } else if(listArguments[["inputs_mode"]]=="two"){
99 results=probmetab(xaP=xaP, xaN=xaN,variableMetadataP=variableMetadataP, variableMetadataN=variableMetadataN, listArguments=listArguments)
100 }
101 #delete the parameters to avoid the passage to the next tool in .RData image
102 #rm(listArguments)
103 cat("\tDONE\n")
104 #saving R data in .Rdata file to save the variables used in the present tool
105 #save.image(paste("probmetab","RData",sep="."))
106