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