changeset 8:6b5504f877ff draft

planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 7b226c3ba91a3cf654ec1c14b3ef85090968bb0f
author lecorguille
date Mon, 05 Mar 2018 04:16:12 -0500
parents dca722aecb67
children 35b9bb3205d8
files README.rst lib.r macros.xml test-data/noclass.merged.sampleMetadata.tsv xcms_merge.r xcms_merge.xml
diffstat 6 files changed, 74 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.rst	Mon Mar 05 04:16:12 2018 -0500
@@ -0,0 +1,13 @@
+
+Changelog/News
+--------------
+
+**Version 1.0.1 - 13/02/2017**
+
+- IMPROVMENT: the tool will now raise an error if a sample isn't describe in the sampleMetadata file
+
+
+**Version 1.0.0 - 03/02/2017**
+
+- NEW: a new tool to merge individual xcmsSet outputs to be used by xcms.group
+
--- a/lib.r	Thu Mar 01 04:15:19 2018 -0500
+++ b/lib.r	Mon Mar 05 04:16:12 2018 -0500
@@ -52,7 +52,7 @@
 
 #@author G. Le Corguille
 # Draw the plotChromPeakDensity 3 per page in a pdf file
-getPlotChromPeakDensity <- function(xdata) {
+getPlotChromPeakDensity <- function(xdata, mzdigit=4) {
     pdf(file="plotChromPeakDensity.pdf", width=16, height=12)
 
     par(mfrow = c(3, 1), mar = c(4, 4, 1, 0.5))
@@ -62,7 +62,9 @@
 
     xlim <- c(min(featureDefinitions(xdata)$rtmin), max(featureDefinitions(xdata)$rtmax))
     for (i in 1:nrow(featureDefinitions(xdata))) {
-        plotChromPeakDensity(xdata, mz=c(featureDefinitions(xdata)[i,]$mzmin,featureDefinitions(xdata)[i,]$mzmax), col=group_colors, pch=16, xlim=xlim)
+        mzmin = featureDefinitions(xdata)[i,]$mzmin
+        mzmax = featureDefinitions(xdata)[i,]$mzmax
+        plotChromPeakDensity(xdata, mz=c(mzmin,mzmax), col=group_colors, pch=16, xlim=xlim, main=paste(round(mzmin,mzdigit),round(mzmax,mzdigit)))
         legend("topright", legend=names(group_colors), col=group_colors, cex=0.8, lty=1)
     }
 
@@ -431,7 +433,7 @@
     files[exists] <- sub("//","/",files[exists])
 
     # WHAT IS ON THE FILESYSTEM
-    filesystem_filepaths <- system(paste("find $PWD/",directory," -not -name '\\.*' -not -path '*conda-env*' -type f -name \"*\"", sep=""), intern=T)
+    filesystem_filepaths <- system(paste0("find \"$PWD/",directory,"\" -not -name '\\.*' -not -path '*conda-env*' -type f -name \"*\""), intern=T)
     filesystem_filepaths <- filesystem_filepaths[grep(filepattern, filesystem_filepaths, perl=T)]
 
     # COMPARISON
@@ -461,7 +463,7 @@
 checkXmlStructure <- function (directory) {
     cat("Checking XML structure...\n")
 
-    cmd <- paste("IFS=$'\n'; for xml in $(find",directory,"-not -name '\\.*' -not -path '*conda-env*' -type f -iname '*.*ml*'); do if [ $(xmllint --nonet --noout \"$xml\" 2> /dev/null; echo $?) -gt 0 ]; then echo $xml;fi; done;")
+    cmd <- paste0("IFS=$'\n'; for xml in $(find '",directory,"' -not -name '\\.*' -not -path '*conda-env*' -type f -iname '*.*ml*'); do if [ $(xmllint --nonet --noout \"$xml\" 2> /dev/null; echo $?) -gt 0 ]; then echo $xml;fi; done;")
     capture <- system(cmd, intern=TRUE)
 
     if (length(capture)>0){
@@ -480,7 +482,7 @@
     cat("Checking Non ASCII characters in the XML...\n")
 
     processed <- F
-    l <- system( paste("find",directory, "-not -name '\\.*' -not -path '*conda-env*' -type f -iname '*.*ml*'"), intern=TRUE)
+    l <- system( paste0("find '",directory, "' -not -name '\\.*' -not -path '*conda-env*' -type f -iname '*.*ml*'"), intern=TRUE)
     for (i in l){
         cmd <- paste("LC_ALL=C grep '[^ -~]' \"", i, "\"", sep="")
         capture <- suppressWarnings(system(cmd, intern=TRUE))
@@ -538,8 +540,8 @@
         singlefile_sampleNames <- args$singlefile_sampleNameNegative
     }
     if (exists("singlefile_galaxyPaths")){
-        singlefile_galaxyPaths <- unlist(strsplit(singlefile_galaxyPaths,","))
-        singlefile_sampleNames <- unlist(strsplit(singlefile_sampleNames,","))
+        singlefile_galaxyPaths <- unlist(strsplit(singlefile_galaxyPaths,"\\|"))
+        singlefile_sampleNames <- unlist(strsplit(singlefile_sampleNames,"\\|"))
 
         singlefile <- NULL
         for (singlefile_galaxyPath_i in seq(1:length(singlefile_galaxyPaths))) {
--- a/macros.xml	Thu Mar 01 04:15:19 2018 -0500
+++ b/macros.xml	Mon Mar 05 04:16:12 2018 -0500
@@ -6,6 +6,7 @@
             <requirement type="package" version="@WRAPPER_VERSION@">bioconductor-xcms</requirement>
             <requirement type="package" version="1.1_4">r-batch</requirement>
             <requirement type="package" version="1.1_2">r-rcolorbrewer</requirement>
+            <requirement type="package" version="6.0">unzip</requirement>
             <yield />
         </requirements>
     </xml>
@@ -24,13 +25,25 @@
         sh -c "exit \$return"
     </token>
 
+    <xml name="input_validator_range_integer">
+        <validator type="regex" message="The format is 'min,max'" >[0-9]+ *, *[0-9]+</validator>
+    </xml>
+
+    <xml name="input_validator_range_float">
+        <validator type="regex" message="The format is 'min,max'" >[0-9]+\.?[0-9]* *, *[0-9]+\.?[0-9]*</validator>
+    </xml>
+
+    <xml name="input_validator_list_integer">
+        <validator type="regex" message="The format is '1,2,4,6'" >[0-9, ]+</validator>
+    </xml>
+
     <!-- zipfile load for planemo test -->
 
     <token name="@COMMAND_FILE_LOAD@">
         #if $file_load_section.file_load_conditional.file_load_select == "yes":
             #if $file_load_section.file_load_conditional.input[0].is_of_type("mzxml") or $file_load_section.file_load_conditional.input[0].is_of_type("mzml") or $file_load_section.file_load_conditional.input[0].is_of_type("mzdata") or $file_load_section.file_load_conditional.input[0].is_of_type("netcdf"):
-                #set singlefile_galaxyPath = ','.join( [ str( $single_file ) for $single_file in $file_load_section.file_load_conditional.input ] )
-                #set singlefile_sampleName = ','.join( [ str( $single_file.name ) for $single_file in $file_load_section.file_load_conditional.input ] )
+                #set singlefile_galaxyPath = '|'.join( [ str( $single_file ) for $single_file in $file_load_section.file_load_conditional.input ] )
+                #set singlefile_sampleName = '|'.join( [ str( $single_file.name ) for $single_file in $file_load_section.file_load_conditional.input ] )
 
                 singlefile_galaxyPath '$singlefile_galaxyPath' singlefile_sampleName '$singlefile_sampleName'
             #else
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/noclass.merged.sampleMetadata.tsv	Mon Mar 05 04:16:12 2018 -0500
@@ -0,0 +1,5 @@
+sampleMetadata	class
+ko15	.
+ko16	.
+wt15	.
+wt16	.
--- a/xcms_merge.r	Thu Mar 01 04:15:19 2018 -0500
+++ b/xcms_merge.r	Mon Mar 05 04:16:12 2018 -0500
@@ -23,6 +23,7 @@
 
 for(image in args$images) {
     load(image)
+    if (!exists("xdata")) stop("\n\nERROR: The RData doesn't contain any object called 'xdata'. This RData should have been created by an old version of XMCS 2.*")
     cat(sampleNamesList$sampleNamesOrigin,"\n")
     if (!exists("xdata_merged")) {
         xdata_merged <- xdata
@@ -63,7 +64,23 @@
         stop(error_message)
     }
 }
-save.image()
+
+# Create a sampleMetada file
+sampleNamesList <- getSampleMetadata(xdata=xdata, sampleMetadataOutput="sampleMetadata.tsv")
+
+# Get the legacy xcmsSet object
+xset <- getxcmsSetObject(xdata)
+
+cat("\n\n")
+
+
+# -- TIC --
+cat("\t\tGET TIC GRAPH\n")
+#@TODO: one day, use xdata instead of xset to draw the TICs and BPC or a complete other method
+getTICs(xcmsSet=xset, rt="raw", pdfname="TICs.pdf")
+getBPCs(xcmsSet=xset, rt="raw", pdfname="BICs.pdf")
+
+cat("\n\n")
 
 cat("\tXCMSnExp OBJECT INFO\n")
 print(pData(xdata))
--- a/xcms_merge.xml	Thu Mar 01 04:15:19 2018 -0500
+++ b/xcms_merge.xml	Mon Mar 05 04:16:12 2018 -0500
@@ -29,10 +29,16 @@
 
     <outputs>
         <data name="xsetRData" format="rdata.xcms.raw" label="xset.merged.RData" from_work_dir="merged.RData" />
+        <data name="sampleMetadataOutput" format="tabular" label="xset.merged.sampleMetadata.tsv" from_work_dir="sampleMetadata.tsv">
+            <filter>not sampleMetadata</filter>
+        </data>
+        <data name="ticsRawPdf" format="pdf" label="xset.merged.xset.TICs_raw.pdf" from_work_dir="TICs.pdf"  />
+        <data name="bpcsRawPdf" format="pdf" label="xset.merged.xset.BPCs_raw.pdf" from_work_dir="BICs.pdf" />
     </outputs>
 
     <tests>
-        <!--<test>
+        <!-- DISABLE FOR TRAVIS
+        <test>
             <param name="images" value="ko15-xset.RData,ko16-xset.RData,wt15-xset.RData,wt16-xset.RData" />
             <expand macro="test_file_load_single"/>
             <assert_stdout>
@@ -43,7 +49,9 @@
                 <has_text text="Peak Groups: 0" />
                 <has_text text="Sample classes: ." />
             </assert_stdout>
-        </test>-->
+            <output name="sampleMetadataOutput" file="noclass.merged.sampleMetadata.tsv" />
+        </test>
+        -->
         <test>
             <param name="images" value="ko15-xset.RData,ko16-xset.RData,wt15-xset.RData,wt16-xset.RData" />
             <expand macro="test_file_load_single"/>
@@ -165,6 +173,10 @@
 
 - UPGRADE: upgrade the xcms version from 1.46.0 to 3.0.0. So refactoring of a lot of underlining codes and methods
 
+**Version 1.0.1 - 13/02/2017**
+
+- IMPROVMENT: the tool will now raise an error if a sample isn't describe in the sampleMetadata file
+
 **Version 1.0.0 - 03/02/2017**
 
 - NEW: a new tool to merge individual xcmsSet outputs to be used by xcms.group