diff macros.xml @ 13:4d5aae46f850 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/query_tabular commit 35576d64a12fa664d72559172c5960c09da2b632"
author iuc
date Thu, 19 Aug 2021 19:39:58 +0000
parents 37cde8134c6a
children 557ec8d7087d
line wrap: on
line diff
--- a/macros.xml	Sat Jun 19 14:16:06 2021 +0000
+++ b/macros.xml	Thu Aug 19 19:39:58 2021 +0000
@@ -32,7 +32,12 @@
     #elif $fi.filter.filter_type == 'select_columns':
       #set $filter_dict = dict()
       #set $filter_dict['filter'] = str($fi.filter.filter_type)
-      #set $filter_dict['columns'] = [int(str($ci).replace('c','')) for $ci in str($fi.filter.columns).split(',')]
+      #set $filter_dict['columns'] = [int($c) for $c in str($fi.filter.columns).replace('c','').split(',')]
+      #silent $input_filters.append($filter_dict)
+    #elif $fi.filter.filter_type == 'select_column_slices':
+      #set $filter_dict = dict()
+      #set $filter_dict['filter'] = str($fi.filter.filter_type)
+      #set $filter_dict['columns'] = [$c for $c in str($fi.filter.columns).split(',')]
       #silent $input_filters.append($filter_dict)
     #elif $fi.filter.filter_type == 'replace':
       #set $filter_dict = dict()
@@ -53,6 +58,11 @@
       #set $filter_dict['filter'] = str($fi.filter.filter_type)
       #set $filter_dict['column_text'] = str($fi.filter.column_text)
       #silent $input_filters.append($filter_dict)
+    #elif str($fi.filter.filter_type).endswith('pend_dataset_name'):
+      #set $filter_dict = dict()
+      #set $filter_dict['filter'] = str($fi.filter.filter_type).replace('dataset_name', 'text')
+      #set $filter_dict['column_text'] = $dataset_name
+      #silent $input_filters.append($filter_dict)
     #elif $fi.filter.filter_type == 'normalize':
       #set $filter_dict = dict()
       #set $filter_dict['filter'] = str($fi.filter.filter_type)
@@ -129,9 +139,12 @@
                             <option value="comment">comment char</option>
                             <option value="regex">by regex expression matching</option>
                             <option value="select_columns">select columns</option>
+                            <option value="select_column_slices">select columns by indices/slices</option>
                             <option value="replace">regex replace value in column</option>
                             <option value="prepend_line_num">prepend a line number column</option>
                             <option value="append_line_num">append a line number column</option>
+                            <option value="prepend_dataset_name">prepend a column with the dataset name</option>
+                            <option value="append_dataset_name">append a column with the dataset name</option>
                             <option value="prepend_text">prepend a column with the given text</option>
                             <option value="append_text">append a column with the given text</option>
                             <option value="normalize">normalize list columns, replicates row for each item in list</option>
@@ -147,6 +160,8 @@
                         </when>
                         <when value="prepend_line_num"/>
                         <when value="append_line_num"/>
+                        <when value="prepend_dataset_name"/>
+                        <when value="append_dataset_name"/>
                         <when value="prepend_text">
                             <param name="column_text" type="text" value="" label="text for column">
                             </param>
@@ -172,6 +187,26 @@
                                 <validator type="regex" message="Column ordinal positions separated by commas">^(c?[1-9]\d*)(,c?[1-9]\d*)*$</validator>
                             </param>
                         </when>
+                        <when value="select_column_slices">
+                            <param name="columns" type="text" value="" label="enter indices or slices of the columns to keep">
+                                <help><![CDATA[ Python offset indexes or slices.  Examples:
+                                 <ul>
+                                 <li>Column offset indexes: 0,3,1 (selects the first,fourth, and second columns)</li>
+                                 <li>Negative column numbers: -1,-2 (selects the last, and second last columns)</li>
+                                 <li>python slices ( slice(start, stop[, step]) select a range of columns): <li>
+                                   <ul>
+                                     <li>0:3 or :3 (selects the first 3 columns)</li>
+                                     <li>3:5 (selects the fourth and fifth columns)</li>
+                                     <li>2: (selects all columns after the second)</li>
+                                     <li>-2: (selects the last 2 columns)</li>
+                                     <li>2::-1 (selects the first 3 columns n reverse order: third,second,first)</li>
+                                   </ul>
+                                 </ul>
+                                ]]></help>
+                                <validator type="regex" message="Column ordinal positions separated by commas">^(-?[1-9]\d*|((-?\d+)?:(-?\d*(:-?\d*)?)))(,(-?[1-9]\d*|((-?\d+)?:(-?\d*(:-?\d*)?))))*$</validator>
+                            </param>
+                        </when>
+
                         <when value="replace">
                             <param name="column" type="text" value="" label="enter column number to replace"
                                 help="example: 1 or c1 (selects the first column)">
@@ -211,21 +246,24 @@
 <![CDATA[
 **Input Line Filters**
 
-  As a tabular file is being read, line filters may be applied.  
-
-  ::
+  As a tabular file is being read, line filters may be applied:
 
-  - skip leading lines              skip the first *number* of lines
-  - comment char                    omit any lines that start with the specified comment character 
-  - by regex expression matching    *include/exclude* lines the match the regex expression 
-  - select columns                  choose to include only selected columns in the order specified 
-  - regex replace value in column   replace a field in a column using a regex substitution (good for date reformatting)
-  - regex replace value in column   add a new column using a regex substitution of a column value
-  - prepend a line number column    each line has the ordinal value of the line read by this filter as the first column
-  - append a line number column     each line has the ordinal value of the line read by this filter as the last column
-  - prepend a text column           each line has the text string as the first column
-  - append a text column            each line has the text string as the last column
-  - normalize list columns          replicates the line for each item in the specified list *columns*
+    - skip leading lines                - skip the first *number* of lines
+    - comment char                      - omit any lines that start with the specified comment character 
+    - by regex expression matching      - *include/exclude* lines that match the regex expression 
+    - select columns                    - choose to include only selected columns in the order specified 
+    - select columns by indices/slices  - *indices or slices* of the columns to keep (python_list_ indexing)
+    - regex replace value in column     - replace a field in a column using a regex substitution (good for date reformatting)
+    - regex replace value in column     - add a new column using a regex substitution of a column value
+    - prepend a line number column      - each line has the *ordinal* value of the line read by this filter as the first column
+    - append a line number column       - each line has the *ordinal* value of the line read by this filter as the last column
+    - prepend a text column             - each line has the text string as the first column
+    - append a text column              - each line has the text string as the last column
+    - prepend the dataset name          - each line has the *dataset name* as the first column
+    - append the dataset name           - each line has the *dataset name* as the last column
+    - normalize list columns            - replicates the line for each item in the specified list *columns*
+
+.. _python_list: https://docs.python.org/3/library/stdtypes.html#common-sequence-operations
 ]]>
   </token>
 
@@ -284,13 +322,13 @@
     0    Jane                Doe        1978-05-24                      5  3
     1    James               Smith      1980-10-20  Spot                6  4
 
-    Filter 6 - append a line number column:
+    Filter 6 - select columns by indices/slices: '1:6'
 
-    2    Paula               Brown      1978-05-24  Rex       dog       3  1  1
-    2    Paula               Brown      1978-05-24  Fluff     cat       3  1  2
-    1    Steven              Jones      1974-04-04  Allie     cat       4  2  3
-    0    Jane                Doe        1978-05-24                      5  3  4
-    1    James               Smith      1980-10-20  Spot                6  4  5
+    Paula               Brown      1978-05-24  Rex       dog
+    Paula               Brown      1978-05-24  Fluff     cat
+    Steven              Jones      1974-04-04  Allie     cat
+    Jane                Doe        1978-05-24               
+    James               Smith      1980-10-20  Spot         
 
 ]]>
   </token>