Mercurial > repos > mmonsoor > probmetab
comparison probmetab.r @ 0:e13ec2c3fabe draft
planemo upload commit 25fd6a739741295e3f434e0be0286dee61e06825
author | mmonsoor |
---|---|
date | Mon, 04 Jul 2016 04:29:25 -0400 |
parents | |
children | abcfa1648b66 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e13ec2c3fabe |
---|---|
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 | |
32 # ----- PROCESSING INFILE ----- | |
33 cat("\tINFILE PROCESSING INFO\n") | |
34 | |
35 # ----- INFILE PROCESSING ----- | |
36 | |
37 if(listArguments[["mode_acquisition"]]=="one") { | |
38 load(listArguments[["xa"]]) | |
39 | |
40 if (!is.null(listArguments[["zipfile"]])){ | |
41 zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL | |
42 } | |
43 | |
44 #Unzip the chromatograms file for plotting EIC pour the HTML file | |
45 if(exists("zipfile")) | |
46 { | |
47 if (zipfile!=""){ | |
48 directory=unzip(zipfile) | |
49 } | |
50 } | |
51 if (!exists("xa")) { | |
52 xa=xsAnnotate_object | |
53 } | |
54 source_local("lib.r") | |
55 if (!exists("variableMetadata")) variableMetadata= getVariableMetadata(xa); | |
56 | |
57 } else if(listArguments[["inputs_mode"]]=="two"){ | |
58 load(listArguments[["image_pos"]]) | |
59 | |
60 if (!is.null(listArguments[["zipfile"]])){ | |
61 zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL | |
62 } | |
63 | |
64 #Unzip the chromatograms file for plotting EIC pour the HTML file | |
65 if(exists("zipfile")) { | |
66 if (zipfile!=""){ | |
67 directory=unzip(zipfile) | |
68 } | |
69 } | |
70 if (!exists("xa")) { | |
71 xa=xsAnnotate_object | |
72 } | |
73 xaP=xa | |
74 source_local("lib.r") | |
75 if (!exists("variableMetadata")) variableMetadataP= getVariableMetadata(xa) | |
76 else variableMetadataP=variableMetadata | |
77 | |
78 | |
79 load(listArguments[["image_neg"]]) | |
80 | |
81 if (!is.null(listArguments[["zipfile"]])){ | |
82 zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL | |
83 } | |
84 | |
85 #Unzip the chromatograms file for plotting EIC pour the HTML file | |
86 if(exists("zipfile")) { | |
87 | |
88 if (zipfile!=""){ | |
89 directory=unzip(zipfile) | |
90 } | |
91 } | |
92 if (!exists("xa")) { | |
93 xa=xsAnnotate_object | |
94 } | |
95 xaN=xa | |
96 source_local("lib.r") | |
97 | |
98 if (!exists("variableMetadata")) variableMetadataN= getVariableMetadata(xa) | |
99 else variableMetadataN=variableMetadata | |
100 } | |
101 | |
102 #Import the different functions | |
103 source_local("lib.r") | |
104 source_local("export.class.table-color-graph.R") | |
105 | |
106 # ----- PROCESSING INFO ----- | |
107 cat("\tMAIN PROCESSING INFO\n") | |
108 | |
109 if(listArguments[["mode_acquisition"]]=="one") { | |
110 results=probmetab(xa=xa, variableMetadata=variableMetadata,listArguments=listArguments) | |
111 } else if(listArguments[["inputs_mode"]]=="two"){ | |
112 results=probmetab(xaP=xaP, xaN=xaN,variableMetadataP=variableMetadataP, variableMetadataN=variableMetadataN, listArguments=listArguments) | |
113 } | |
114 #delete the parameters to avoid the passage to the next tool in .RData image | |
115 #rm(listArguments) | |
116 cat("\tDONE\n") | |
117 #saving R data in .Rdata file to save the variables used in the present tool | |
118 #save.image(paste("probmetab","RData",sep=".")) | |
119 |