comparison probmetab.r @ 3:abcfa1648b66 draft

planemo upload commit c897279aa8cae0a4ad889bb05b143f32d2b6d712
author lecorguille
date Fri, 07 Apr 2017 07:14:12 -0400
parents e13ec2c3fabe
children
comparison
equal deleted inserted replaced
2:3a9914b37f2f 3:abcfa1648b66
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
25 options(bitmapType='cairo')
26
24 cat("\n\n") 27 cat("\n\n")
28
29
25 # ----- ARGUMENTS ----- 30 # ----- ARGUMENTS -----
26 cat("\tARGUMENTS INFO\n") 31 cat("\tARGUMENTS INFO\n")
27 listArguments = parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects 32 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') 33 write.table(as.matrix(listArguments), col.names=F, quote=F, sep='\t')
29 34
30 35
31 36
33 cat("\tINFILE PROCESSING INFO\n") 38 cat("\tINFILE PROCESSING INFO\n")
34 39
35 # ----- INFILE PROCESSING ----- 40 # ----- INFILE PROCESSING -----
36 41
37 if(listArguments[["mode_acquisition"]]=="one") { 42 if(listArguments[["mode_acquisition"]]=="one") {
38 load(listArguments[["xa"]]) 43 load(listArguments[["image"]])
39 44 cat("\t\tXA OBJECT INFO\n")
40 if (!is.null(listArguments[["zipfile"]])){ 45 print(xa)
41 zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL 46
42 } 47 source_local("lib.r")
43 48 if (!exists("zipfile")) zipfile=NULL
44 #Unzip the chromatograms file for plotting EIC pour the HTML file 49 if (!exists("singlefile")) singlefile=NULL
45 if(exists("zipfile")) 50 rawFilePath = getRawfilePathFromArguments(singlefile, zipfile, listArguments)
46 { 51 zipfile = rawFilePath$zipfile
47 if (zipfile!=""){ 52 singlefile = rawFilePath$singlefile
48 directory=unzip(zipfile) 53 retrieveRawfileInTheWorkingDirectory(singlefile, zipfile)
49 } 54
50 } 55 if (!exists("variableMetadata")) variableMetadata= getVariableMetadata(xa);
51 if (!exists("xa")) { 56
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"){ 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 58
59 # POSITIVE
60 load(listArguments[["image_pos"]])
78 61
79 load(listArguments[["image_neg"]]) 62 if (!exists("xa")) xaP=xsAnnotate_object
80 63 else xaP=xa
81 if (!is.null(listArguments[["zipfile"]])){ 64 cat("\t\tXA-POSITIVE OBJECT INFO\n")
82 zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL 65 print(xaP)
83 } 66
84 67 if (!exists("variableMetadata")) variableMetadataP = getVariableMetadata(xa)
85 #Unzip the chromatograms file for plotting EIC pour the HTML file 68 else variableMetadataP = variableMetadata
86 if(exists("zipfile")) { 69
87 70 source_local("lib.r")
88 if (zipfile!=""){ 71 if (!exists("zipfile")) zipfile=NULL
89 directory=unzip(zipfile) 72 if (!exists("singlefile")) singlefile=NULL
90 } 73 rawFilePath = getRawfilePathFromArguments(singlefile, zipfile, listArguments)
91 } 74 zipfilePos = rawFilePath$zipfile
92 if (!exists("xa")) { 75 singlefilePos = rawFilePath$singlefile
93 xa=xsAnnotate_object 76 retrieveRawfileInTheWorkingDirectory(singlefilePos, zipfilePos)
94 } 77
95 xaN=xa 78 # NEGATIVE
96 source_local("lib.r") 79 load(listArguments[["image_neg"]])
97 80
98 if (!exists("variableMetadata")) variableMetadataN= getVariableMetadata(xa) 81 if (!exists("xa")) xaN=xsAnnotate_object
99 else variableMetadataN=variableMetadata 82 else xaN=xa
83 cat("\t\tXA-NEGATIVE OBJECT INFO\n")
84 print(xaP)
85
86 if (!exists("variableMetadata")) variableMetadataN = getVariableMetadata(xa)
87 else variableMetadataN = variableMetadata
88
89 source_local("lib.r")
90 if (!exists("zipfile")) zipfile=NULL
91 if (!exists("singlefile")) singlefile=NULL
92 rawFilePath = getRawfilePathFromArguments(singlefile, zipfile, listArguments)
93 zipfileNeg = rawFilePath$zipfile
94 singlefileNeg = rawFilePath$singlefile
95 retrieveRawfileInTheWorkingDirectory(singlefileNeg, zipfileNeg)
100 } 96 }
101 97
102 #Import the different functions 98 #Import the different functions
103 source_local("lib.r") 99 source_local("lib.r")
104 source_local("export.class.table-color-graph.R") 100 source_local("export.class.table-color-graph.R")
105 101
106 # ----- PROCESSING INFO ----- 102 # ----- PROCESSING INFO -----
107 cat("\tMAIN PROCESSING INFO\n") 103 cat("\tMAIN PROCESSING INFO\n")
108 104
109 if(listArguments[["mode_acquisition"]]=="one") { 105 if(listArguments[["mode_acquisition"]]=="one") {
110 results=probmetab(xa=xa, variableMetadata=variableMetadata,listArguments=listArguments) 106 results=probmetab(xa=xa, variableMetadata=variableMetadata,listArguments=listArguments)
111 } else if(listArguments[["inputs_mode"]]=="two"){ 107 } else if(listArguments[["inputs_mode"]]=="two"){
112 results=probmetab(xaP=xaP, xaN=xaN,variableMetadataP=variableMetadataP, variableMetadataN=variableMetadataN, listArguments=listArguments) 108 results=probmetab(xaP=xaP, xaN=xaN,variableMetadataP=variableMetadataP, variableMetadataN=variableMetadataN, listArguments=listArguments)
113 } 109 }
114 #delete the parameters to avoid the passage to the next tool in .RData image 110 #delete the parameters to avoid the passage to the next tool in .RData image
115 #rm(listArguments) 111 #rm(listArguments)
116 cat("\tDONE\n") 112 cat("\tDONE\n")
117 #saving R data in .Rdata file to save the variables used in the present tool 113 #saving R data in .Rdata file to save the variables used in the present tool
118 #save.image(paste("probmetab","RData",sep=".")) 114 #save.image(paste("probmetab","RData",sep="."))
119