Mercurial > repos > lecorguille > xcms_group
comparison xcms.r @ 20:a79d839d625f draft
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 87dc789d7cd70a3733a1ad0b5a427f4d5905795d
author | lecorguille |
---|---|
date | Wed, 01 Mar 2017 16:56:48 -0500 |
parents | a28473761624 |
children | beda2d981b9d |
comparison
equal
deleted
inserted
replaced
19:7f667b64d5a5 | 20:a79d839d625f |
---|---|
69 if (!is.null(listArguments[["rplotspdf"]])){ | 69 if (!is.null(listArguments[["rplotspdf"]])){ |
70 rplotspdf = listArguments[["rplotspdf"]]; listArguments[["rplotspdf"]]=NULL | 70 rplotspdf = listArguments[["rplotspdf"]]; listArguments[["rplotspdf"]]=NULL |
71 } | 71 } |
72 sampleMetadataOutput = "sampleMetadata.tsv" | 72 sampleMetadataOutput = "sampleMetadata.tsv" |
73 if (!is.null(listArguments[["sampleMetadataOutput"]])){ | 73 if (!is.null(listArguments[["sampleMetadataOutput"]])){ |
74 sampleMetadataOutput = listArguments[["sampleMetadataOutput"]]; listArguments[["sampleMetadataOutput"]]=NULL | 74 sampleMetadataOutput = listArguments[["sampleMetadataOutput"]]; listArguments[["sampleMetadataOutput"]]=NULL |
75 } | 75 } |
76 variableMetadataOutput = "variableMetadata.tsv" | 76 variableMetadataOutput = "variableMetadata.tsv" |
77 if (!is.null(listArguments[["variableMetadataOutput"]])){ | 77 if (!is.null(listArguments[["variableMetadataOutput"]])){ |
78 variableMetadataOutput = listArguments[["variableMetadataOutput"]]; listArguments[["variableMetadataOutput"]]=NULL | 78 variableMetadataOutput = listArguments[["variableMetadataOutput"]]; listArguments[["variableMetadataOutput"]]=NULL |
79 } | 79 } |
97 if (thefunction %in% c("xcmsSet","retcor")) { | 97 if (thefunction %in% c("xcmsSet","retcor")) { |
98 ticspdf = listArguments[["ticspdf"]]; listArguments[["ticspdf"]]=NULL | 98 ticspdf = listArguments[["ticspdf"]]; listArguments[["ticspdf"]]=NULL |
99 bicspdf = listArguments[["bicspdf"]]; listArguments[["bicspdf"]]=NULL | 99 bicspdf = listArguments[["bicspdf"]]; listArguments[["bicspdf"]]=NULL |
100 } | 100 } |
101 | 101 |
102 #necessary to unzip .zip file uploaded to Galaxy | 102 |
103 #thanks to .zip file it's possible to upload many file as the same time conserving the tree hierarchy of directories | |
104 | |
105 | |
106 if (!is.null(listArguments[["zipfile"]])){ | |
107 zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL | |
108 } | |
109 | |
110 if (!is.null(listArguments[["singlefile_galaxyPath"]])){ | |
111 singlefile_galaxyPaths = unlist(strsplit(listArguments[["singlefile_galaxyPath"]],",")); listArguments[["singlefile_galaxyPath"]]=NULL | |
112 singlefile_sampleNames = unlist(strsplit(listArguments[["singlefile_sampleName"]],",")); listArguments[["singlefile_sampleName"]]=NULL | |
113 | |
114 singlefile=NULL | |
115 for (singlefile_galaxyPath_i in seq(1:length(singlefile_galaxyPaths))) { | |
116 singlefile_galaxyPath=singlefile_galaxyPaths[singlefile_galaxyPath_i] | |
117 singlefile_sampleName=singlefile_sampleNames[singlefile_galaxyPath_i] | |
118 singlefile[[singlefile_sampleName]] = singlefile_galaxyPath | |
119 } | |
120 } | |
121 | |
122 # We unzip automatically the chromatograms from the zip files. | |
123 if (thefunction %in% c("xcmsSet","retcor","fillPeaks")) { | 103 if (thefunction %in% c("xcmsSet","retcor","fillPeaks")) { |
124 if(exists("singlefile") && (length("singlefile")>0)) { | 104 rawFilePath = getRawfilePathFromArguments(listArguments) |
125 for (singlefile_sampleName in names(singlefile)) { | 105 zipfile = rawFilePath$zipfile |
126 singlefile_galaxyPath = singlefile[[singlefile_sampleName]] | 106 singlefile = rawFilePath$singlefile |
127 if(!file.exists(singlefile_galaxyPath)){ | 107 listArguments = rawFilePath$listArguments |
128 error_message=paste("Cannot access the sample:",singlefile_sampleName,"located:",singlefile_galaxyPath,". Please, contact your administrator ... if you have one!") | 108 directory = retrieveRawfileInTheWorkingDirectory(singlefile, zipfile) |
129 print(error_message); stop(error_message) | 109 md5sumList=list("origin"=getMd5sum(directory)) |
130 } | |
131 | |
132 file.symlink(singlefile_galaxyPath,singlefile_sampleName) | |
133 } | |
134 directory = "." | |
135 | |
136 md5sumList=list("origin"=getMd5sum(directory)) | |
137 | |
138 } | |
139 if(exists("zipfile") && (zipfile!="")) { | |
140 if(!file.exists(zipfile)){ | |
141 error_message=paste("Cannot access the Zip file:",zipfile,". Please, contact your administrator ... if you have one!") | |
142 print(error_message) | |
143 stop(error_message) | |
144 } | |
145 | |
146 #list all file in the zip file | |
147 #zip_files=unzip(zipfile,list=T)[,"Name"] | |
148 | |
149 #unzip | |
150 suppressWarnings(unzip(zipfile, unzip="unzip")) | |
151 | |
152 #get the directory name | |
153 filesInZip=unzip(zipfile, list=T); | |
154 directories=unique(unlist(lapply(strsplit(filesInZip$Name,"/"), function(x) x[1]))); | |
155 directories=directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir] | |
156 directory = "." | |
157 if (length(directories) == 1) directory = directories | |
158 | |
159 cat("files_root_directory\t",directory,"\n") | |
160 | |
161 md5sumList=list("origin"=getMd5sum(directory)) | |
162 } | |
163 } | 110 } |
164 | 111 |
165 #addition of the directory to the list of arguments in the first position | 112 #addition of the directory to the list of arguments in the first position |
166 if (thefunction == "xcmsSet") { | 113 if (thefunction == "xcmsSet") { |
167 checkXmlStructure(directory) | 114 checkXmlStructure(directory) |
221 | 168 |
222 if (thefunction == "xcmsSet") { | 169 if (thefunction == "xcmsSet") { |
223 | 170 |
224 #transform the files absolute pathways into relative pathways | 171 #transform the files absolute pathways into relative pathways |
225 xset@filepaths<-sub(paste(getwd(),"/",sep="") ,"", xset@filepaths) | 172 xset@filepaths<-sub(paste(getwd(),"/",sep="") ,"", xset@filepaths) |
226 | 173 print(zipfile) |
227 if(exists("zipfile") && (zipfile!="")) { | 174 if(exists("zipfile") && !is.null(zipfile) && (zipfile!="")) { |
228 | 175 |
229 #Modify the samples names (erase the path) | 176 #Modify the samples names (erase the path) |
230 for(i in 1:length(sampnames(xset))){ | 177 for(i in 1:length(sampnames(xset))){ |
231 | 178 |
232 sample_name=unlist(strsplit(sampnames(xset)[i], "/")) | 179 sample_name=unlist(strsplit(sampnames(xset)[i], "/")) |