| 
22
 | 
     1 <tool id="filter_tabular" name="Filter Tabular" version="5.0.0">
 | 
| 
20
 | 
     2     <description></description>
 | 
| 
 | 
     3 
 | 
| 
 | 
     4     <macros>
 | 
| 
 | 
     5          <import>macros.xml</import>
 | 
| 
 | 
     6     </macros>
 | 
| 
 | 
     7 
 | 
| 
 | 
     8     <requirements>
 | 
| 
 | 
     9     </requirements>
 | 
| 
21
 | 
    10     <command detect_errors="exit_code"><![CDATA[
 | 
| 
 | 
    11         python '$__tool_directory__/filter_tabular.py'
 | 
| 
20
 | 
    12         -i '$input'
 | 
| 
 | 
    13         -j '$filter_json'
 | 
| 
 | 
    14         -o '$output'
 | 
| 
 | 
    15     ]]></command>
 | 
| 
 | 
    16     <configfiles>
 | 
| 
 | 
    17         <configfile name="filter_json">
 | 
| 
 | 
    18 #import json
 | 
| 
 | 
    19 @LINEFILTERS@
 | 
| 
 | 
    20 #if $input_filters:
 | 
| 
 | 
    21 #echo $json.dumps($input_filters)
 | 
| 
 | 
    22 #end if
 | 
| 
 | 
    23         </configfile>
 | 
| 
 | 
    24     </configfiles>
 | 
| 
 | 
    25     <inputs>
 | 
| 
 | 
    26         <param name="input" type="data" format="tabular" label="Tabular Dataset to filter"/>
 | 
| 
 | 
    27         <expand macro="macro_line_filters" />
 | 
| 
 | 
    28     </inputs>
 | 
| 
 | 
    29     <outputs>
 | 
| 
 | 
    30         <data format="tabular" name="output" />
 | 
| 
 | 
    31     </outputs>
 | 
| 
 | 
    32     <tests>
 | 
| 
 | 
    33         <test>
 | 
| 
 | 
    34             <param name="input" ftype="tabular" value="pets.tsv"/>
 | 
| 
 | 
    35             <repeat name="linefilters">
 | 
| 
21
 | 
    36                 <conditional name="filter">
 | 
| 
 | 
    37                     <param name="filter_type" value="regex"/>
 | 
| 
 | 
    38                     <param name="regex_pattern" value="^\d+"/>
 | 
| 
 | 
    39                     <param name="regex_action" value="include_find"/>
 | 
| 
 | 
    40                 </conditional>
 | 
| 
20
 | 
    41             </repeat>
 | 
| 
 | 
    42             <repeat name="linefilters">
 | 
| 
21
 | 
    43                 <conditional name="filter">
 | 
| 
 | 
    44                     <param name="filter_type" value="append_line_num"/>
 | 
| 
 | 
    45                 </conditional>
 | 
| 
20
 | 
    46             </repeat>
 | 
| 
 | 
    47             <repeat name="linefilters">
 | 
| 
21
 | 
    48                 <conditional name="filter">
 | 
| 
 | 
    49                     <param name="filter_type" value="select_columns"/>
 | 
| 
 | 
    50                     <param name="columns" value="7,2,3,4,1"/>
 | 
| 
 | 
    51                 </conditional>
 | 
| 
20
 | 
    52             </repeat>
 | 
| 
 | 
    53             <repeat name="linefilters">
 | 
| 
21
 | 
    54                 <conditional name="filter">
 | 
| 
 | 
    55                     <param name="filter_type" value="replace"/>
 | 
| 
 | 
    56                     <param name="column" value="c4"/>
 | 
| 
 | 
    57                     <param name="regex_pattern" value="(\d+)/(\d+)/(\d+)"/>
 | 
| 
 | 
    58                     <param name="regex_replace" value="19\3-\2-\1"/>
 | 
| 
 | 
    59                 </conditional>
 | 
| 
20
 | 
    60             </repeat>
 | 
| 
 | 
    61             <output name="output" file="filtered_people_results.tsv"/>
 | 
| 
 | 
    62         </test>
 | 
| 
 | 
    63         <test>
 | 
| 
 | 
    64             <param name="input" ftype="tabular" value="pets.tsv"/>
 | 
| 
 | 
    65             <repeat name="linefilters">
 | 
| 
21
 | 
    66                 <conditional name="filter">
 | 
| 
 | 
    67                     <param name="filter_type" value="comment"/>
 | 
| 
 | 
    68                     <param name="comment_char" value="35"/>
 | 
| 
 | 
    69                 </conditional>
 | 
| 
20
 | 
    70             </repeat>
 | 
| 
 | 
    71             <repeat name="linefilters">
 | 
| 
21
 | 
    72                 <conditional name="filter">
 | 
| 
 | 
    73                     <param name="filter_type" value="regex"/>
 | 
| 
 | 
    74                     <param name="regex_pattern" value="^\d+"/>
 | 
| 
 | 
    75                     <param name="regex_action" value="include_find"/>
 | 
| 
 | 
    76                 </conditional>
 | 
| 
 | 
    77             </repeat>
 | 
| 
 | 
    78             <repeat name="linefilters">
 | 
| 
 | 
    79                 <conditional name="filter">
 | 
| 
 | 
    80                     <param name="filter_type" value="append_line_num"/>
 | 
| 
 | 
    81                 </conditional>
 | 
| 
20
 | 
    82             </repeat>
 | 
| 
 | 
    83             <repeat name="linefilters">
 | 
| 
21
 | 
    84                 <conditional name="filter">
 | 
| 
 | 
    85                     <param name="filter_type" value="select_columns"/>
 | 
| 
 | 
    86                     <param name="columns" value="c7,c5,c6"/>
 | 
| 
 | 
    87                 </conditional>
 | 
| 
20
 | 
    88             </repeat>
 | 
| 
 | 
    89             <repeat name="linefilters">
 | 
| 
21
 | 
    90                 <conditional name="filter">
 | 
| 
 | 
    91                     <param name="filter_type" value="normalize"/>
 | 
| 
 | 
    92                     <param name="columns" value="c2,c3"/>
 | 
| 
 | 
    93                     <param name="separator" value=","/>
 | 
| 
 | 
    94                 </conditional>
 | 
| 
 | 
    95             </repeat>
 | 
| 
 | 
    96             <repeat name="linefilters">
 | 
| 
 | 
    97                 <conditional name="filter">
 | 
| 
 | 
    98                     <param name="filter_type" value="regex"/>
 | 
| 
 | 
    99                     <param name="regex_pattern" value="^\d+\t\t"/>
 | 
| 
 | 
   100                     <param name="regex_action" value="exclude_match"/>
 | 
| 
 | 
   101                 </conditional>
 | 
| 
20
 | 
   102             </repeat>
 | 
| 
 | 
   103             <output name="output" file="filtered_pets_results.tsv"/>
 | 
| 
 | 
   104         </test>
 | 
| 
 | 
   105 
 | 
| 
 | 
   106     </tests>
 | 
| 
 | 
   107     <help><![CDATA[
 | 
| 
 | 
   108 ==============
 | 
| 
 | 
   109 Filter Tabular
 | 
| 
 | 
   110 ==============
 | 
| 
 | 
   111 
 | 
| 
 | 
   112   Filter a tabular dataset by applying line filters as it is being read.
 | 
| 
 | 
   113   Multiple filters may be used with each filter using the result of the previous filter.  
 | 
| 
 | 
   114 
 | 
| 
 | 
   115 **Inputs**
 | 
| 
 | 
   116 
 | 
| 
 | 
   117   A tabular dataset.
 | 
| 
 | 
   118 
 | 
| 
 | 
   119 
 | 
| 
 | 
   120 **Outputs**
 | 
| 
 | 
   121 
 | 
| 
 | 
   122   A filtered tabular dataset.
 | 
| 
 | 
   123 
 | 
| 
 | 
   124 
 | 
| 
 | 
   125 @LINEFILTERS_HELP@
 | 
| 
 | 
   126 
 | 
| 
 | 
   127 @LINEFILTERS_HELP_EXAMPLE@
 | 
| 
 | 
   128 
 | 
| 
 | 
   129     ]]></help>
 | 
| 
 | 
   130 </tool>
 |