diff export_to_spreadsheet.xml @ 3:72a7f23f3a79 draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit c3917e27eb1c1deeb381aa0dc8161c07699562fb"
author bgruening
date Mon, 11 May 2020 07:46:16 -0400
parents c956182d4e2c
children d0178bdcd00e
line wrap: on
line diff
--- a/export_to_spreadsheet.xml	Thu Apr 16 05:32:53 2020 -0400
+++ b/export_to_spreadsheet.xml	Mon May 11 07:46:16 2020 -0400
@@ -2,6 +2,27 @@
     <description>export measurements into one or more files</description>
     <macros>
         <import>macros.xml</import>
+        <xml name="metadata_sample_row" >
+            <param name="metadata_category" type="select" label="Select the metadata to use as the identifier">
+                <option value="FileName">File name</option>
+
+                <option value="Frame">Frame</option>
+                <option value="Height">Height</option>
+                <option value="MD5Digest">MD5Digest</option>
+                <option value="PathName">Path name</option>
+
+                <option value="Scaling">Scaling</option>
+                <option value="Series">Series</option>
+                <option value="URL">URL</option>
+                <option value="Width">Width</option>
+            </param>
+            <param name="metadata_measurement" type="text" label="Measurements" >
+                <help>
+                    Choose the measurement that corresponds to the identifier, such as metadata from the Metadata tool. Please see the Metadata tool for more details on metadata collection and usage.
+
+                </help>
+            </param>
+        </xml>
     </macros>
 
     <expand macro="py_requirements"/>
@@ -27,35 +48,39 @@
     _str += FOURSPACES + "Select the column delimiter:%s\n" % params["delimiter"]
     _str += FOURSPACES + "Add image metadata columns to your object data file?:%s\n" % params["add_metadata_column_to_object"]
 
-    measurement = params["con_measurement_export"]
 
-    _str += FOURSPACES + "Select the measurements to export:%s\n" % measurement['export_measurement']
+    _str += FOURSPACES + "Select the measurements to export:No\n"  
     _str += FOURSPACES + "Calculate the per-image mean values for object measurements?:%s\n" % params['calc_mean']
     _str += FOURSPACES + "Calculate the per-image median values for object measurements?:%s\n" % params['calc_median']
     _str += FOURSPACES + "Calculate the per-image standard deviation values for object measurements?:%s\n" % params['calc_standard_deviation']
-    _str += FOURSPACES + "Output file location:%s\\x7C\n" % params['output_file_location']
+    _str += FOURSPACES + "Output file location:Default Output Folder\\x7C\n"
 
     create_gene = params["con_create_gene_pattern"]["create_gene_pattern"]
+    _str += FOURSPACES + "Create a GenePattern GCT file?:%s\n" % create_gene
+    
 
-    if create_gene == "No":
-        _str += FOURSPACES + "Create a GenePattern GCT file?:%s\n" % create_gene
-        _str += FOURSPACES + "Select source of sample row name:Metadata\n"
-        _str += FOURSPACES + "Select the image to use as the identifier:None\n"
-        _str += FOURSPACES + "Select the metadata to use as the identifier:None\n"
-    else:
-        _str += FOURSPACES + "Create a GenePattern GCT file?:%s\n" % create_gene
-        _str += FOURSPACES + "Select the image to use as the identifier:None\n"
-        _str += FOURSPACES + "Select the metadata to use as the identifier:None\n"
+    #default values when create gene  is no
+    source_sample_row = "Metadata"
+    image_as_id = "None"
+    metadata_as_id = "None"
+    
+    if create_gene == "Yes":
+        source_sample_row = params["con_create_gene_pattern"]["con_source_sample_row"]["select_source_sample_row_name"]
+        if source_sample_row == "Metadata":
+            metadata_as_id = params["con_create_gene_pattern"]["con_source_sample_row"]["metadata_category"] + "_" + params["con_create_gene_pattern"]["con_source_sample_row"]["metadata_measurement"]
+        else:
+            image_as_id = params["con_create_gene_pattern"]["con_source_sample_row"]["image_filename_cat"]
+
+    _str += FOURSPACES + "Select source of sample row name:%s\n" % source_sample_row
+    _str += FOURSPACES + "Select the image to use as the identifier:%s\n" % image_as_id
+    _str += FOURSPACES + "Select the metadata to use as the identifier:%s\n" % metadata_as_id
+
 
     export_all_measurements = params["con_export_all_measurements"]["export_all_measurements"]
 
-    if export_all_measurements == "Yes":
-        _str += FOURSPACES + "Export all measurement types?:%s\n" % export_all_measurements
+    _str += FOURSPACES + "Export all measurement types?:%s\n" % export_all_measurements
 
-    if 'select_measurements' in params['con_measurement_export']:
-        _str += FOURSPACES + "Press button to select measurements:%s\n" % params['con_measurement_export']['select_measurements']
-    else:
-        _str += FOURSPACES + "Press button to select measurements:\n"
+    _str += FOURSPACES + "Press button to select measurements:\n"
 
     _str += FOURSPACES + "Representation of Nan/Inf:%s\n" % params["represent_nan"]
     _str += FOURSPACES + "Add a prefix to file names?:%s\n" % params["con_prefix"]["add_prefix"]
@@ -67,13 +92,28 @@
 
     _str += FOURSPACES + "Overwrite existing files without warning?:%s\n" % params["overwrite_existing_file"]
 
+
+    use_as_filename = "Yes"
+
     if export_all_measurements == "Yes":
         _str += FOURSPACES + "Data to export:Do not use\n"
         _str += FOURSPACES + "Combine these object measurements with those of the previous object?:No\n"
         _str += FOURSPACES + "File name:DATA.csv\n"
         _str += FOURSPACES + "Use the object name for the file name?:Yes\n"
     else:
-        _str += FOURSPACES + "Data to export:%s\n" % params["con_export_all_measurements"]["data_to_export"]
+        for dte in params["con_export_all_measurements"]["r_data_to_export"]:
+            _str += FOURSPACES + "Data to export:%s\n" % dte["data_to_export"]
+            _str += FOURSPACES + "Combine these object measurements with those of the previous object?:No\n"
+            
+            use_as_filename = dte["con_obj_name_for_filename"]["use_as_filename"]
+
+            if use_as_filename == "No":
+                file_name = dte["con_obj_name_for_filename"]["file_name"]
+            else:
+                file_name = "DATA.csv"
+
+            _str += FOURSPACES + "File name:%s\n" % file_name
+            _str += FOURSPACES + "Use the object name for the file name?:%s\n" % use_as_filename
 
     return _str
 
@@ -85,31 +125,28 @@
     module_count = int(v)
     new_count = module_count + 1
     lines[4] = k + ":%d\n" % new_count
-    with open("output", "w") as f:
+    with open("output.cppipe", "w") as f:
         f.writelines(lines)
         f.write(write_etss())
 
-f.close()
+    f.close()
         </configfile>
     </configfiles>
 
     <inputs>
-        <expand macro="input_pipeline_macro" />
+        <expand macro="input_pipeline_param" />
         <param name="delimiter" type="select" label="Select the column delimiter">
             <option value="Comma (&quot;,&quot;)">Comma (",")</option>
             <option value="Tab">Tab</option>
             <sanitizer sanitize="false"/>
         </param>
-        <param name="output_file_location" type="select" label="Output file location">
-            <option value="Default Output Folder"/>
-        </param>
         <conditional name="con_prefix">
-            <param name="add_prefix" type="select" display="radio" label="Add a prefix to file names?">
-                <option value="Yes">Yes</option>
-                <option value="No">No</option>
+            <param name="add_prefix" type="select" label="Add a prefix to file names?">
+                <option value="Yes">Add prefix to the file name</option>
+                <option value="No">Do not add prefix to the file name</option>
             </param>
             <when value="Yes">
-                <param name="filename_prefix" type="text" label="Filename prefix"/>
+                <param name="filename_prefix" type="text" value="MyExpt_" label="Enter the prefix to be added to the file names"/>
             </when>
             <when value="No" />
         </conditional>
@@ -117,89 +154,92 @@
             <option value="Yes">Yes</option>
             <option value="No">No</option>
         </param>
-        <param name="add_metadata_column_to_object" display="radio" type="select" label="Add image metadata columns to  your object data file?">
+        <param name="add_metadata_column_to_object" display="radio" type="select" label="Add image metadata columns to  your object data file?" help="'Image_Metadata_' columns are normally exported in the Image data file, but if you select 'Yes', they will also be exported with the Object data file(s).">
             <option value="Yes">Yes</option>
             <option value="No">No</option>
-        </param>       
-        <param name="represent_nan" type="select" label="Representation of Nan/Inf">
+        </param>
+        <param name="represent_nan" type="select" label="Representation of Nan/Inf" help="CellProfiler will produce Inf or NaN values under certain rare circumstances, for instance when calculating the mean intensity of an object within a masked region of an image.">
             <option value="NaN">NaN</option>
             <option value="Null">Null</option>
         </param>
-        <conditional name="con_measurement_export">
-            <param name="export_measurement" type="select" display="radio" label="Select the measurements to export">
-                <option value="Yes">Yes</option>
-                <option value="No">No</option>
-            </param>
-            <when value="Yes">
-                <param name="select_measurement" type="text" label="Select measurements"/>
-            </when>
-            <when value="No" />
-        </conditional>
-        <param name="calc_mean" type="select" display="radio" label="Calculate the per-image mean values for object measurments">
+        <param name="calc_mean" type="select" display="radio" label="Calculate the per-image mean values for object measurements?" help="Select 'Yes' to calculate the population mean over all the objects in each image and save that value as an aggregate measurement in the image file.">
             <option value="Yes">Yes</option>
             <option value="No">No</option>
         </param>
-        <param name="calc_median" type="select" display="radio" label="Calculate the per-image median values for object measurments">
+        <param name="calc_median" type="select" display="radio" label="Calculate the per-image median values for object measurements?" help="Select 'Yes' to calculate the population median over all the objects in each image and save that value as an aggregate measurement in the image file.">
             <option value="Yes">Yes</option>
             <option value="No">No</option>
-        </param>  
-        <param name="calc_standard_deviation" type="select" display="radio" label="Calculate the per-image standard deviation values for object measurments">
+        </param>
+        <param name="calc_standard_deviation" type="select" display="radio" label="Calculate the per-image standard deviation values for object measurements?" help="Select 'Yes' to calculate the population standard deviation over all the objects in each image and save that value as an aggregate measurement in the image file.">
             <option value="Yes">Yes</option>
             <option value="No">No</option>
         </param>
         <conditional name="con_create_gene_pattern">
-            <param name="create_gene_pattern" type="select" display="radio" label="Create a GenePattern GCT file?">
+            <param name="create_gene_pattern" type="select" display="radio" label="Create a GenePattern GCT file?" help="Select 'Yes' to create a GCT file compatible with GenePattern. The GCT file format is a tab-delimited text file format designed for gene expression datasets; the specifics of the format are described here. By converting your measurements into a GCT file, you can make use of GenePattern’s data visualization and clustering methods.">
                 <option value="Yes">Yes</option>
-                <option value="No">No</option>
+                <option value="No" selected="true">No</option>
             </param>
             <when value="Yes">
                 <conditional name="con_source_sample_row">
                     <param name="select_source_sample_row_name" type="select" label="Select source of sample row name">
+                        <help>
+                            <![CDATA[
+                                The first column of the GCT file is the unique identifier for each sample, which is ordinarily the gene name. This information may be specified in one of two ways:
+                                <br> - Metadata: If you used the Metadata modules to add metadata to your images, you may specify a metadata tag that corresponds to the identifier for this column.
+                                <br> - Image filename: If the gene name is not available, the image filename can be used as a surrogate identifier.
+                                ]]>
+                        </help>
                         <option value="Metadata">Metadata</option>
                         <option value="Image filename">Image filename</option>
                     </param>
+               
                     <when value="Metadata">
-                        <param name="metadata_cat" type="select" label="Select the metadata to use as the indentifier">
-                            <option value="AreaOccupied">AreaOccupied</option>
-                        </param>
+                        <expand macro="metadata_sample_row" />
                     </when>
                     <when value="Image filename">
-                        <param name="image_filename_cat" type="select" label="Select the image to use as the indentifier">
-                            <option value="None">None</option>
-                        </param>
+                        <param name="image_filename_cat" type="text" value="None" label="Enter the name of the image to use as the identifier" help="Enter the name of the image image whose filename will be used to identify each sample row. " />  
+
                     </when>
                 </conditional>
             </when>
             <when value="No" />
         </conditional>
         <conditional name="con_export_all_measurements">
-            <param name="export_all_measurements" type="select" display="radio" label="Export all measuremnt types?">
+            <param name="export_all_measurements" type="select" display="radio" label="Export all measurement types?" help="Select 'Yes' to export every category of measurement. ExportToSpreadsheet will create one data file for each object produced in the pipeline, as well as per-image, per-experiment and object relationships, if relevant.">
                 <option value="Yes">Yes</option>
                 <option value="No">No</option>
             </param>
             <when value="No">
-                <repeat name="r_data_to_export" title="Add another data set">
-                    <param name="data_to_export" type="select" label="Data to export">
+                <repeat name="r_data_to_export" title="another data set" min="1">
+                    <param name="data_to_export" type="select" label="Data to export" help="This option will writ out a file of measurements for the given category.">                        
                         <option value="Image">Image</option>
-                        <option value="Experiment">Experiement</option>
+                        <option value="Experiment">Experiment</option>
                         <option value="Object relationship">Object relationship</option>
+                        <option value="Do not use">Do not use</option>
                     </param>
-                    <param name="use_as_filename" type="select" display="radio" label="Use the object name for the file name?">
-                        <option value="Yes">Yes</option>
-                        <option value="No">No</option>
-                    </param>
+                    <conditional name="con_obj_name_for_filename">
+                        <param name="use_as_filename" type="select" display="radio" label="Use the object name for the file name?" help="Select 'Yes' to use the object name as selected above to generate a file name for the spreadsheet.">
+                            <option value="Yes">Yes</option>
+                            <option value="No">No</option>
+                        </param>
+                        <when value="No">
+                            <param name="file_name" type="text" label="File name" />
+                        </when>
+                        <when value="Yes" />
+                    </conditional>
                 </repeat>
-            </when>   
+            </when>
             <when value="Yes" />
         </conditional>
     </inputs>
 
     <outputs>
-        <expand macro="output_pipeline_macro" />
+        <expand macro="output_pipeline_param" />
     </outputs>
 
     <tests>
         <test>
+        <!-- create gene pattern =no-->
             <expand macro="test_input_pipeline_param" />
             <param name="delimiter" value="Tab" />
             <param name="output_file_location" value="Default Output Folder" />
@@ -218,14 +258,137 @@
             <conditional name="con_create_gene_pattern">
                 <param name="create_gene_pattern" value="No" />
             </conditional>
-            <conditional name="con_export_all_measurements" >
+            <conditional name="con_export_all_measurements">
+                <param name="export_all_measurements" value="Yes" />
+            </conditional>
+            <expand macro="test_out_file" file="export_to_spreadsheet.cppipe" />
+        </test>
+
+        <test>
+            <!-- create gene=yes , source of sampe row name= metadata-->
+            <expand macro="test_input_pipeline_param" />
+            <param name="delimiter" value="Tab" />
+            <param name="output_file_location" value="Default Output Folder" />
+            <conditional name="con_prefix">
+                <param name="add_prefix" value="No"/>
+            </conditional>
+            <param name="overwrite_existing_file" value="Yes" />
+            <param name="add_metadata_column_to_object" value="Yes" />
+            <param name="represent_nan" value="NaN" />
+            <conditional name="con_measurement_export">
+                <param name="export_measurement" value="No" />
+            </conditional>
+            <param name="calc_mean" value="Yes" />
+            <param name="calc_median" value="Yes" />
+            <param name="calc_standard_deviation" value="Yes" />
+            <conditional name="con_create_gene_pattern">
+                <param name="create_gene_pattern" value="Yes" />
+                <conditional name="con_source_sample_row">
+                    <param name="select_source_sample_row_name" value="Metadata" />
+                     <param name="metadata_category" value="FileName" />
+                      <param name="metadata_measurement" value="DNA" />
+                </conditional>
+            </conditional>
+            <conditional name="con_export_all_measurements">
                 <param name="export_all_measurements" value="Yes" />
             </conditional>
-            <expand macro="test_out_file" file="export_to_spreadsheet.txt" />
+            <expand macro="test_out_file" file="export_to_spreadsheet_create_gene_metadata.cppipe" />
+        </test>
+        <test>
+            <!-- create gene=yes , source of sampe row name= image filename, export all = no-->
+            <expand macro="test_input_pipeline_param" />
+            <param name="delimiter" value="Tab" />
+            <param name="output_file_location" value="Default Output Folder" />
+            <conditional name="con_prefix">
+                <param name="add_prefix" value="Yes"/>
+                <param name="filename_prefix" value="MyExpt_" />
+            </conditional>
+            <param name="overwrite_existing_file" value="Yes" />
+            <param name="add_metadata_column_to_object" value="Yes" />
+            <param name="represent_nan" value="NaN" />
+            <conditional name="con_measurement_export">
+                <param name="export_measurement" value="No" />
+            </conditional>
+            <param name="calc_mean" value="Yes" />
+            <param name="calc_median" value="Yes" />
+            <param name="calc_standard_deviation" value="Yes" />
+            <conditional name="con_create_gene_pattern">
+                <param name="create_gene_pattern" value="Yes" />
+                <conditional name="con_source_sample_row">
+                    <param name="select_source_sample_row_name" value="Image filename" />
+                     <param name="image_filename_cat" value="DNA" />
+                </conditional>
+            </conditional>
+            <conditional name="con_export_all_measurements">
+                <param name="export_all_measurements" value="No" />
+                <repeat name="r_data_to_export">
+                    <param name="data_to_export" value="Image" />
+                     <conditional name="con_obj_name_for_filename">
+                        <param name="use_as_filename" value="No" />
+                        <param name="file_name" value="data.csv" />
+                     </conditional>
+                </repeat>
+            </conditional>
+            <expand macro="test_out_file" file="export_to_spreadsheet_create_gene_image_filename.cppipe" />
+        </test>
+
+        <test>
+            <!--repeat test for multiple data export. create gene=yes , source of sampe row name= image filename, export all = no-->
+            <expand macro="test_input_pipeline_param" />
+            <param name="delimiter" value="Tab" />
+            <param name="output_file_location" value="Default Output Folder" />
+            <conditional name="con_prefix">
+                <param name="add_prefix" value="Yes"/>
+                <param name="filename_prefix" value="MyExpt_" />
+            </conditional>
+            <param name="overwrite_existing_file" value="Yes" />
+            <param name="add_metadata_column_to_object" value="Yes" />
+            <param name="represent_nan" value="NaN" />
+            <conditional name="con_measurement_export">
+                <param name="export_measurement" value="No" />
+            </conditional>
+            <param name="calc_mean" value="Yes" />
+            <param name="calc_median" value="Yes" />
+            <param name="calc_standard_deviation" value="Yes" />
+            <conditional name="con_create_gene_pattern">
+                <param name="create_gene_pattern" value="Yes" />
+                <conditional name="con_source_sample_row">
+                    <param name="select_source_sample_row_name" value="Image filename" />
+                     <param name="image_filename_cat" value="DNA" />
+                </conditional>
+            </conditional>
+            <conditional name="con_export_all_measurements">
+                <param name="export_all_measurements" value="No" />
+                <repeat name="r_data_to_export">
+                    <param name="data_to_export" value="Image" />
+                     <conditional name="con_obj_name_for_filename">
+                        <param name="use_as_filename" value="No" />
+                        <param name="file_name" value="data.csv" />
+                     </conditional>
+                </repeat>
+                <repeat name="r_data_to_export">
+                    <param name="data_to_export" value="Experiment" />
+                     <conditional name="con_obj_name_for_filename">
+                        <param name="use_as_filename" value="Yes" />
+                     </conditional>
+                </repeat>
+            </conditional>
+            <expand macro="test_out_file" file="export_to_spreadsheet_multi.cppipe" />
         </test>
     </tests>
 
-    <expand macro="help" module="ExportToSpreadsheet" />
+    <help>
+        <![CDATA[
+            .. class:: infomark
+
+            **What it does**
+
+            This tool will convert the measurements to a comma-, tab-, or other character-delimited text format and save them in one or several files, as requested.
+
+            @COMMON_HELP@
+            ]]>
+    </help>
+
     <expand macro="citations" />
 
 </tool>