view filter_tabular.xml @ 21:357fe86f245d draft

Uploaded
author jjohnson
date Fri, 14 Jul 2017 17:34:22 -0400
parents ab27c4bd14b9
children bed5018e7ae3
line wrap: on
line source

<tool id="filter_tabular" name="Filter Tabular" version="1.0.0">
    <description></description>

    <macros>
         <import>macros.xml</import>
    </macros>

    <requirements>
    </requirements>
    <command detect_errors="exit_code"><![CDATA[
        python '$__tool_directory__/filter_tabular.py'
        -i '$input'
        -j '$filter_json'
        -o '$output'
    ]]></command>
    <configfiles>
        <configfile name="filter_json">
#import json
@LINEFILTERS@
#if $input_filters:
#echo $json.dumps($input_filters)
#end if
        </configfile>
    </configfiles>
    <inputs>
        <param name="input" type="data" format="tabular" label="Tabular Dataset to filter"/>
        <expand macro="macro_line_filters" />
    </inputs>
    <outputs>
        <data format="tabular" name="output" />
    </outputs>
    <tests>
        <test>
            <param name="input" ftype="tabular" value="pets.tsv"/>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="regex"/>
                    <param name="regex_pattern" value="^\d+"/>
                    <param name="regex_action" value="include_find"/>
                </conditional>
            </repeat>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="append_line_num"/>
                </conditional>
            </repeat>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="select_columns"/>
                    <param name="columns" value="7,2,3,4,1"/>
                </conditional>
            </repeat>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="replace"/>
                    <param name="column" value="c4"/>
                    <param name="regex_pattern" value="(\d+)/(\d+)/(\d+)"/>
                    <param name="regex_replace" value="19\3-\2-\1"/>
                </conditional>
            </repeat>
            <output name="output" file="filtered_people_results.tsv"/>
        </test>
        <test>
            <param name="input" ftype="tabular" value="pets.tsv"/>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="comment"/>
                    <param name="comment_char" value="35"/>
                </conditional>
            </repeat>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="regex"/>
                    <param name="regex_pattern" value="^\d+"/>
                    <param name="regex_action" value="include_find"/>
                </conditional>
            </repeat>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="append_line_num"/>
                </conditional>
            </repeat>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="select_columns"/>
                    <param name="columns" value="c7,c5,c6"/>
                </conditional>
            </repeat>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="normalize"/>
                    <param name="columns" value="c2,c3"/>
                    <param name="separator" value=","/>
                </conditional>
            </repeat>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="regex"/>
                    <param name="regex_pattern" value="^\d+\t\t"/>
                    <param name="regex_action" value="exclude_match"/>
                </conditional>
            </repeat>
            <output name="output" file="filtered_pets_results.tsv"/>
        </test>

    </tests>
    <help><![CDATA[
==============
Filter Tabular
==============

  Filter a tabular dataset by applying line filters as it is being read.
  Multiple filters may be used with each filter using the result of the previous filter.  

**Inputs**

  A tabular dataset.


**Outputs**

  A filtered tabular dataset.


@LINEFILTERS_HELP@

@LINEFILTERS_HELP_EXAMPLE@

    ]]></help>
</tool>