view filter_tabular.xml @ 15:90f657745fea draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/query_tabular commit dd35055c76d86fe98985b5825c1751efb8208242
author iuc
date Thu, 27 Jun 2024 17:23:47 +0000
parents 4d5aae46f850
children
line wrap: on
line source

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

    <macros>
         <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <command detect_errors="exit_code"><![CDATA[
        python '$__tool_directory__/filter_tabular.py'
        -i '$input'
        $comment_char
        -j '$filter_json'
        -o '$output'
    ]]></command>
    <configfiles>
        <configfile name="filter_json">
#import json
#set $dataset_name = $input.element_identifier
#set $table=$input
@LINEFILTERS@
#echo $json.dumps($input_filters)
        </configfile>
    </configfiles>
    <inputs>
        <param name="input" type="data" format="tabular" label="Tabular Dataset to filter"/>
        <param name="comment_char" type="boolean" truevalue="--comment_char '#'" falsevalue="" checked="true" label="exclude lines starting with #"/>
        <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>

        <test>
            <param name="input" ftype="tabular" value="customers.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="replace"/>
                    <param name="column" value="c4"/>
                    <param name="regex_pattern" value=".*@(.*)"/>
                    <param name="regex_replace" value="\1"/>
                    <param name="add" value="after"/>
                </conditional>
            </repeat>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="replace"/>
                    <param name="column" value="c4"/>
                    <param name="regex_pattern" value=".*(com|org|net)$"/>
                    <param name="regex_replace" value="\1"/>
                    <param name="add" value="append"/>
                </conditional>
            </repeat>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="replace"/>
                    <param name="column" value="c6"/>
                    <param name="regex_pattern" value="^(\d+)-(\d+)-(\d+)$"/>
                    <param name="regex_replace" value="\1"/>
                    <param name="add" value="prepend"/>
                </conditional>
            </repeat>
            <output name="output" file="filtered_customers_results.tsv"/>
        </test>
        <test>
            <param name="input" ftype="tabular" value="IEDB.tsv"/>
            <param name="comment_char" value="False"/>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="replace"/>
                    <param name="column" value="c1"/>
                    <param name="regex_pattern" value="#ID"/>
                    <param name="regex_replace" value="ID"/>
                </conditional>
            </repeat>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="select_column_slices"/>
                    <param name="columns" value="6,0:6,8,-3"/>
                </conditional>
            </repeat>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="append_dataset_name"/>
                </conditional>
            </repeat>
            <output name="output" file="filtered_IEDB.tsv"/>
        </test>
        <test>
            <param name="input" ftype="tabular" value="math_input.tsv"/>
            <param name="comment_char" value="False"/>
            <repeat name="linefilters">
                <conditional name="filter">
                    <param name="filter_type" value="skip"/>
                    <param name="skiplines" value=""/>
                </conditional>
            </repeat>
            <output name="output" file="math_input.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>
    <expand macro="citations" />
</tool>