changeset 12:ddce949e4b35 draft

planemo upload commit d708b85fc764e790fac071552d19cd7a89d02d31
author lecorguille
date Tue, 28 Mar 2017 10:51:55 -0400
parents d67f7aa847bf
children 97e2c754e81f
files CAMERA.r abims_CAMERA_combinexsAnnos.xml lib.r macros.xml
diffstat 4 files changed, 196 insertions(+), 107 deletions(-) [+]
line wrap: on
line diff
--- a/CAMERA.r	Mon Feb 13 11:19:39 2017 -0500
+++ b/CAMERA.r	Tue Mar 28 10:51:55 2017 -0400
@@ -98,64 +98,13 @@
 #Import the different functions
 source_local("lib.r")
 
-#necessary to unzip .zip file uploaded to Galaxy
-#thanks to .zip file it's possible to upload many file as the same time conserving the tree hierarchy of directories
-
-if (!is.null(listArguments[["zipfile"]])){
-    zipfile= listArguments[["zipfile"]]; listArguments[["zipfile"]]=NULL
-}
-
-if (!is.null(listArguments[["singlefile_galaxyPath"]])){
-    singlefile_galaxyPaths = unlist(strsplit(listArguments[["singlefile_galaxyPath"]],",")); listArguments[["singlefile_galaxyPath"]]=NULL
-    singlefile_sampleNames = unlist(strsplit(listArguments[["singlefile_sampleName"]],",")); listArguments[["singlefile_sampleName"]]=NULL
-
-    singlefile=NULL
-    for (singlefile_galaxyPath_i in seq(1:length(singlefile_galaxyPaths))) {
-        singlefile_galaxyPath=singlefile_galaxyPaths[singlefile_galaxyPath_i]
-        singlefile_sampleName=singlefile_sampleNames[singlefile_galaxyPath_i]
-        singlefile[[singlefile_sampleName]] = singlefile_galaxyPath
-    }
-}
-
 # We unzip automatically the chromatograms from the zip files.
 if (thefunction %in% c("annotatediff"))  {
-    if(exists("singlefile") && (length("singlefile")>0)) {
-        for (singlefile_sampleName in names(singlefile)) {
-            singlefile_galaxyPath = singlefile[[singlefile_sampleName]]
-            if(!file.exists(singlefile_galaxyPath)){
-                error_message=paste("Cannot access the sample:",singlefile_sampleName,"located:",singlefile_galaxyPath,". Please, contact your administrator ... if you have one!")
-                print(error_message); stop(error_message)
-            }
-
-            file.symlink(singlefile_galaxyPath,singlefile_sampleName)
-        }
-        directory = "."
-
-
-    }
-    if(exists("zipfile") && (zipfile!="")) {
-        if(!file.exists(zipfile)){
-            error_message=paste("Cannot access the Zip file:",zipfile,". Please, contact your administrator ... if you have one!")
-            print(error_message)
-            stop(error_message)
-        }
-
-        #list all file in the zip file
-        #zip_files=unzip(zipfile,list=T)[,"Name"]
-
-        #unzip
-        suppressWarnings(unzip(zipfile, unzip="unzip"))
-
-        #get the directory name
-        filesInZip=unzip(zipfile, list=T);
-        directories=unique(unlist(lapply(strsplit(filesInZip$Name,"/"), function(x) x[1])));
-        directories=directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir]
-        directory = "."
-        if (length(directories) == 1) directory = directories
-
-        cat("files_root_directory\t",directory,"\n")
-
-    }
+    rawFilePath = getRawfilePathFromArguments(listArguments)
+    zipfile = rawFilePath$zipfile
+    singlefile = rawFilePath$singlefile
+    listArguments = rawFilePath$listArguments
+    directory = retrieveRawfileInTheWorkingDirectory(singlefile, zipfile)
 }
 
 
--- a/abims_CAMERA_combinexsAnnos.xml	Mon Feb 13 11:19:39 2017 -0500
+++ b/abims_CAMERA_combinexsAnnos.xml	Tue Mar 28 10:51:55 2017 -0400
@@ -54,10 +54,7 @@
             <param name="pos" value="TRUE"/>
             <param name="tol" value="2"/>
             <param name="ruleset" value="1,1"/>
-            <param name="convertRTMinute" value="True"/>
-            <param name="numDigitsMZ" value="4" />
-            <param name="numDigitsRT" value="1" />
-            <param name="intval" value="into"/>
+            <expand macro="test_peaklist"/>
             <output name="variableMetadata" file="faahOK.xset.group.retcor.group.fillPeaks.annotate.positive.combinexsAnnos.variableMetadata.tsv" />
         </test>
     </tests>
--- a/lib.r	Mon Feb 13 11:19:39 2017 -0500
+++ b/lib.r	Tue Mar 28 10:51:55 2017 -0400
@@ -223,3 +223,84 @@
     return(variableMetadata);
 
 }
+
+# This function get the raw file path from the arguments
+getRawfilePathFromArguments <- function(listArguments) {
+    zipfile = NULL
+    singlefile = NULL
+    if (!is.null(listArguments[["zipfile"]]))           zipfile = listArguments[["zipfile"]]
+    if (!is.null(listArguments[["zipfilePositive"]]))   zipfile = listArguments[["zipfilePositive"]]
+    if (!is.null(listArguments[["zipfileNegative"]]))   zipfile = listArguments[["zipfileNegative"]]
+
+    if (!is.null(listArguments[["singlefile_galaxyPath"]])) {
+        singlefile_galaxyPaths = listArguments[["singlefile_galaxyPath"]];
+        singlefile_sampleNames = listArguments[["singlefile_sampleName"]]
+    }
+    if (!is.null(listArguments[["singlefile_galaxyPathPositive"]])) {
+        singlefile_galaxyPaths = listArguments[["singlefile_galaxyPathPositive"]];
+        singlefile_sampleNames = listArguments[["singlefile_sampleNamePositive"]]
+    }
+    if (!is.null(listArguments[["singlefile_galaxyPathNegative"]])) {
+        singlefile_galaxyPaths = listArguments[["singlefile_galaxyPathNegative"]];
+        singlefile_sampleNames = listArguments[["singlefile_sampleNameNegative"]]
+    }
+    if (exists("singlefile_galaxyPaths")){
+        singlefile_galaxyPaths = unlist(strsplit(singlefile_galaxyPaths,","))
+        singlefile_sampleNames = unlist(strsplit(singlefile_sampleNames,","))
+
+        singlefile=NULL
+        for (singlefile_galaxyPath_i in seq(1:length(singlefile_galaxyPaths))) {
+            singlefile_galaxyPath=singlefile_galaxyPaths[singlefile_galaxyPath_i]
+            singlefile_sampleName=singlefile_sampleNames[singlefile_galaxyPath_i]
+            singlefile[[singlefile_sampleName]] = singlefile_galaxyPath
+        }
+    }
+    for (argument in c("zipfile","zipfilePositive","zipfileNegative","singlefile_galaxyPath","singlefile_sampleName","singlefile_galaxyPathPositive","singlefile_sampleNamePositive","singlefile_galaxyPathNegative","singlefile_sampleNameNegative")) {
+        listArguments[[argument]]=NULL
+    }
+    return(list(zipfile=zipfile, singlefile=singlefile, listArguments=listArguments))
+}
+
+
+# This function retrieve the raw file in the working directory
+#   - if zipfile: unzip the file with its directory tree
+#   - if singlefiles: set symlink with the good filename
+retrieveRawfileInTheWorkingDirectory <- function(singlefile, zipfile) {
+    if(!is.null(singlefile) && (length("singlefile")>0)) {
+        for (singlefile_sampleName in names(singlefile)) {
+            singlefile_galaxyPath = singlefile[[singlefile_sampleName]]
+            if(!file.exists(singlefile_galaxyPath)){
+                error_message=paste("Cannot access the sample:",singlefile_sampleName,"located:",singlefile_galaxyPath,". Please, contact your administrator ... if you have one!")
+                print(error_message); stop(error_message)
+            }
+
+            file.symlink(singlefile_galaxyPath,singlefile_sampleName)
+        }
+        directory = "."
+
+    }
+    if(!is.null(zipfile) && (zipfile!="")) {
+        if(!file.exists(zipfile)){
+            error_message=paste("Cannot access the Zip file:",zipfile,". Please, contact your administrator ... if you have one!")
+            print(error_message)
+            stop(error_message)
+        }
+
+        #list all file in the zip file
+        #zip_files=unzip(zipfile,list=T)[,"Name"]
+
+        #unzip
+        suppressWarnings(unzip(zipfile, unzip="unzip"))
+
+        #get the directory name
+        filesInZip=unzip(zipfile, list=T);
+        directories=unique(unlist(lapply(strsplit(filesInZip$Name,"/"), function(x) x[1])));
+        directories=directories[!(directories %in% c("__MACOSX")) & file.info(directories)$isdir]
+        directory = "."
+        if (length(directories) == 1) directory = directories
+
+        cat("files_root_directory\t",directory,"\n")
+
+    }
+    return (directory)
+}
--- a/macros.xml	Mon Feb 13 11:19:39 2017 -0500
+++ b/macros.xml	Tue Mar 28 10:51:55 2017 -0400
@@ -2,12 +2,11 @@
 <macros>
     <xml name="requirements">
         <requirements>
-	    <requirement type="package" version="0.4_1">r-snow</requirement>
+            <requirement type="package" version="0.4_1">r-snow</requirement>
             <requirement type="package" version="1.26.0">bioconductor-camera</requirement>
             <requirement type="package" version="2.26.0">bioconductor-multtest</requirement>
-	    <requirement type="package" version="1.1_4">r-batch</requirement>
-            <requirement type="package" version="1.6.27">libpng</requirement>
-            <requirement type="package" version="1.3.20">graphicsmagick</requirement>
+            <requirement type="package" version="1.1_4">r-batch</requirement>
+            <requirement type="package" version="1.3.23">graphicsmagick</requirement>
         </requirements>
     </xml>
     <xml name="stdio">
@@ -20,61 +19,124 @@
         LANG=C Rscript $__tool_directory__/CAMERA.r
     </token>
 
-    <!-- zipfile load for planemo test -->
+    <!-- raw file load for planemo test -->
     <token name="@COMMAND_FILE_LOAD@">
-        #if $file_load_conditional.file_load_select == "yes":
-            #if $file_load_conditional.inputs.input == "zip_file":
-                zipfile '$file_load_conditional.inputs.zip_file'
+        #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 ] )
+                singlefile_galaxyPath '$singlefile_galaxyPath' singlefile_sampleName '$singlefile_sampleName'
             #else
-                #set singlefile_galaxyPath = ','.join( [ str( $single_file ) for $single_file in $file_load_conditional.inputs.single_file ] )
-                #set singlefile_sampleName = ','.join( [ str( $single_file.name ) for $single_file in $file_load_conditional.inputs.single_file ] )
-
-                singlefile_galaxyPath '$singlefile_galaxyPath' singlefile_sampleName '$singlefile_sampleName'
+                zipfile '$file_load_section.file_load_conditional.input'
             #end if
         #end if
     </token>
 
-    <xml name="file_load">
-        <conditional name="file_load_conditional">
-            <param name="file_load_select" type="select" label="Resubmit your dataset or your zip file" help="Use only if you get a message which say that your original dataset or zip file have been deleted on the server." >
-                <option value="no" >no need</option>
-                <option value="yes" >yes</option>
-            </param>
-            <when value="no">
-            </when>
-            <when value="yes">
-                <conditional name="inputs">
-                    <param name="input" type="select" label="Choose your inputs method" >
-                        <option value="zip_file" selected="true">Zip file from your history containing your chromatograms</option>
-                        <option value="single_file">A mzXML or netCDF file from your history</option>
-                    </param>
-                    <when value="zip_file">
-                        <param name="zip_file" type="data" format="no_unzip.zip,zip" label="Zip file" />
-                    </when>
-                    <when value="single_file">
-                        <param name="single_file" type="data" format="mzxml,netcdf" label="Single file"  multiple="true"/>
-                    </when>
-                </conditional>
-            </when>
-        </conditional>
+    <xml name="input_file_load">
+        <section name="file_load_section" title="Resubmit your raw dataset or your zip file">
+            <conditional name="file_load_conditional">
+                <param name="file_load_select" type="select" label="Resubmit your dataset or your zip file" help="Use only if you get a message which say that your original dataset or zip file have been deleted on the server." >
+                    <option value="no" >no need</option>
+                    <option value="yes" >yes</option>
+                </param>
+                <when value="no">
+                </when>
+                <when value="yes">
+                    <param name="input" type="data" format="mzxml,mzml,mzdata,netcdf,no_unzip.zip,zip" multiple="true" label="File(s) from your history containing your chromatograms" help="Single file mode for the format: mzxml, mzml, mzdata and netcdf. Zip file mode for the format: no_unzip.zip, zip. See the help section below." />
+                </when>
+            </conditional>
+        </section>
     </xml>
 
+    <xml name="test_file_load_zip">
+        <section name="file_load_section">
+            <conditional name="file_load_conditional">
+                <param name="file_load_select" value="yes" />
+                <param name="input" value="faahKO_reduce.zip" ftype="zip" />
+            </conditional>
+        </section>
+    </xml>
+
+    <xml name="test_file_load_single">
+        <section name="file_load_section">
+            <conditional name="file_load_conditional">
+                <param name="file_load_select" value="yes" />
+                <param name="input" value="wt15.CDF,ko16.CDF,ko15.CDF,wt16.CDF" ftype="netcdf" />
+            </conditional>
+        </section>
+    </xml>
+
+    <!-- peaklist export option management -->
     <token name="@COMMAND_PEAKLIST@">
-        convertRTMinute $convertRTMinute
-        numDigitsMZ $numDigitsMZ
-        numDigitsRT $numDigitsRT
-        intval $intval
+        convertRTMinute $export.convertRTMinute
+        numDigitsMZ $export.numDigitsMZ
+        numDigitsRT $export.numDigitsRT
+        intval $export.intval
     </token>
 
     <xml name="input_peaklist">
-        <param name="convertRTMinute" type="boolean" checked="false" truevalue="TRUE" falsevalue="FALSE" label="Convert retention time (seconds) into minutes" help="Convert the columns rtmed, rtmin and rtmax into minutes"/>
-        <param name="numDigitsMZ" type="integer" value="4" label="Number of decimal places for mass values reported in ions' identifiers." help="A minimum of 4 decimal places is recommended. Useful to avoid duplicates within identifiers" />
-        <param name="numDigitsRT" type="integer" value="0" label="Number of decimal places for retention time values reported in ions' identifiers." help="Useful to avoid duplicates within identifiers" />
-        <param name="intval" type="select" label="General used intensity value" help="[intval] See the help section below">
-            <option value="into" selected="true">into</option>
-            <option value="maxo" >maxo</option>
-            <option value="intb">intb</option>
-        </param>
+        <section name="export" title="Export options">
+            <param name="convertRTMinute" type="boolean" checked="false" truevalue="TRUE" falsevalue="FALSE" label="Convert retention time (seconds) into minutes" help="Convert the columns rtmed, rtmin and rtmax into minutes"/>
+            <param name="numDigitsMZ" type="integer" value="4" label="Number of decimal places for mass values reported in ions' identifiers." help="A minimum of 4 decimal places is recommended. Useful to avoid duplicates within identifiers" />
+            <param name="numDigitsRT" type="integer" value="0" label="Number of decimal places for retention time values reported in ions' identifiers." help="Useful to avoid duplicates within identifiers" />
+            <param name="intval" type="select" label="General used intensity value" help="[intval] See the help section below">
+                <option value="into" selected="true">into</option>
+                <option value="maxo" >maxo</option>
+                <option value="intb">intb</option>
+            </param>
+        </section>
+    </xml>
+
+    <xml name="test_peaklist">
+        <section name="export">
+            <param name="convertRTMinute" value="True"/>
+            <param name="numDigitsMZ" value="4" />
+            <param name="numDigitsRT" value="1" />
+            <param name="intval" value="into"/>
+        </section>
+    </xml>
+
+    <!-- annotate_diffreport <test> commun part -->
+    <xml name="test_annotate_diffreport">
+        <section name="groupfwhm">
+            <param name="sigma" value="6"/>
+            <param name="perfwhm" value="0.6"/>
+        </section>
+        <section name="findisotopes">
+            <param name="maxcharge" value="3"/>
+            <param name="maxiso" value="4"/>
+            <param name="minfrac" value="0.5"/>
+        </section>
+        <section name="general">
+            <param name="ppm" value="5"/>
+            <param name="mzabs" value="0.015"/>
+            <param name="max_peaks" value="100"/>
+        </section>
+        <section name="diffreport">
+        <conditional name="options">
+            <param name="option" value="show"/>
+            <param name="eicmax" value="200"/>
+            <param name="eicwidth" value="200"/>
+            <param name="value" value="into"/>
+            <param name="h" value="480"/>
+            <param name="w" value="640"/>
+            <param name="mzdec" value="2"/>
+            <param name="sortpval" value="False"/>
+        </conditional>
+        </section>
+        <expand macro="test_peaklist"/>
+    </xml>
+
+    <xml name="test_annotate_diffreport_quick">
+        <param name="quick" value="FALSE"/>
+        <section name="groupcorr">
+            <param name="cor_eic_th" value="0.75"/>
+            <param name="graphMethod" value="hcs"/>
+            <param name="pval" value="0.05"/>
+            <param name="calcCiS" value="True"/>
+            <param name="calcIso" value="False"/>
+            <param name="calcCaS" value="False"/>
+        </section>
     </xml>
 
     <token name="@HELP_AUTHORS@">