comparison xcms.r @ 6:60f6c208ca16 draft

planemo upload commit a3229faad6949bbca965d1d7e138cb3c0550780e
author lecorguille
date Thu, 07 Apr 2016 15:02:32 -0400
parents b9a87af62223
children f28041d2180a
comparison
equal deleted inserted replaced
5:b9a87af62223 6:60f6c208ca16
75 } 75 }
76 76
77 77
78 78
79 79
80 if (thefunction == "xcmsSet" || thefunction == "retcor") { 80 if (thefunction %in% c("xcmsSet","retcor")) {
81 ticspdf = listArguments[["ticspdf"]]; listArguments[["ticspdf"]]=NULL 81 ticspdf = listArguments[["ticspdf"]]; listArguments[["ticspdf"]]=NULL
82 bicspdf = listArguments[["bicspdf"]]; listArguments[["bicspdf"]]=NULL 82 bicspdf = listArguments[["bicspdf"]]; listArguments[["bicspdf"]]=NULL
83 } 83 }
84 84
85 #necessary to unzip .zip file uploaded to Galaxy 85 #necessary to unzip .zip file uploaded to Galaxy
98 stop(error_message) 98 stop(error_message)
99 } 99 }
100 } 100 }
101 101
102 # We unzip automatically the chromatograms from the zip files. 102 # We unzip automatically the chromatograms from the zip files.
103 if (thefunction == "xcmsSet" || thefunction == "retcor" || thefunction == "fillPeaks") { 103 if (thefunction %in% c("xcmsSet","retcor","fillPeaks")) {
104 if(exists("zipfile") && (zipfile!="")) { 104 if(exists("zipfile") && (zipfile!="")) {
105 if(!file.exists(zipfile)){ 105 if(!file.exists(zipfile)){
106 error_message=paste("Cannot access the Zip file:",zipfile,". Please, contact your administrator ... if you have one!") 106 error_message=paste("Cannot access the Zip file:",zipfile,". Please, contact your administrator ... if you have one!")
107 print(error_message) 107 print(error_message)
108 stop(error_message) 108 stop(error_message)
109 } 109 }
110 110
111 #list all file in the zip file 111 #list all file in the zip file
112 #zip_files=unzip(zipfile,list=T)[,"Name"] 112 #zip_files=unzip(zipfile,list=T)[,"Name"]
113 113
114 #get the directory name
115 filesInZIp=unzip(zipfile, list=T);
116 directories=unique(unlist(lapply(strsplit(filesInZIp$Name,"/"), function(x) x[1])));
117 directories=directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir]
118 if (length(directories) == 1) directory=directories else directory=".";
119 114
120 #unzip 115 #unzip
121 suppressWarnings(unzip(zipfile, unzip="unzip")) 116 suppressWarnings(unzip(zipfile, unzip="unzip"))
117
118 #get the directory name
119 filesInZip=unzip(zipfile, list=T);
120 directories=unique(unlist(lapply(strsplit(filesInZip$Name,"/"), function(x) x[1])));
121 directories=directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir]
122 directory = "."
123 if (length(directories) == 1) directory = directories
124
125 cat("files_root_directory\t",directory,"\n")
122 126
123 # 127 #
124 md5sumList=list("origin"=getMd5sum(directory)) 128 md5sumList=list("origin"=getMd5sum(directory))
125 129
126 # Check and fix if there are non ASCII characters. If so, they will be removed from the *mzXML mzML files. 130 # Check and fix if there are non ASCII characters. If so, they will be removed from the *mzXML mzML files.
188 192
189 cat("\n\n") 193 cat("\n\n")
190 194
191 dev.off() #dev.new(file="Rplots.pdf", width=16, height=12) 195 dev.off() #dev.new(file="Rplots.pdf", width=16, height=12)
192 196
193 if (thefunction == "xcmsSet") { 197 if (thefunction == "xcmsSet") {
194 198
195 #transform the files absolute pathways into relative pathways 199 #transform the files absolute pathways into relative pathways
196 xset@filepaths<-sub("^.*/database/job_working_directory/[0123456789]+/[0123456789]+/" ,"", xset@filepaths) 200 xset@filepaths<-sub(paste(getwd(),"/",sep="") ,"", xset@filepaths)
197 xset@filepaths<-sub("^.*/database/jobs/[0123456789]+/[0123456789]+/" ,"", xset@filepaths) 201
198 if(exists("zipfile") && (zipfile!="")) { 202 if(exists("zipfile") && (zipfile!="")) {
199 203
200 #Modify the samples names (erase the path) 204 #Modify the samples names (erase the path)
201 for(i in 1:length(sampnames(xset))){ 205 for(i in 1:length(sampnames(xset))){
202 206