<tool id="macs2_filterdup" name="MACS2 filterdup" version="2.0.10.0">
    <description>Remove duplicate reads at the same position</description>
    <expand macro="requirements" />
    <expand macro="version_command" />
    <macros>
        <import>macs2_macros.xml</import>
    </macros>
    <command>
        macs2 filterdup
            -i "${ infile }"
            -o "${ outfile }"

        --format '${ infile.extension.upper() }'
        @effective_genome_size@
        @tag_size@
        --pvalue "${ pvalue }"
        #if str( $keep_dup_options.keep_dup_options_selector ) == "user":
            --keep-dup "${ keep_dup_options.user_keepdup }"
        #else
            --keep-dup "${ keep_dup_options.keep_dup_options_selector }"
        #end if
    </command>
    <expand macro="stdio" />
    <inputs>
        <param name="infile" type="data" format="sam,bam,bed" label="Sequencing alignment file" />
        <expand macro="conditional_effective_genome_size" />
        <expand macro="tag_size" />
        <param name="pvalue" type="text" value="1e-5" label="Pvalue cutoff for binomial distribution test" help="default: 1e-5 (--pvalue)" />

        <conditional name="keep_dup_options">
            <param name="keep_dup_options_selector" type="select" label="controlling behavior of duplicate tags at the exact same location"
                help="It controls the 'macs2 filterdup' behavior towards duplicate tags at the exact same location (the same coordination and the same strand. The default 'auto') option makes 'macs2 filterdup' calculate the maximum tags at the exact same location based on binomal distribution using given -p as pvalue cutoff; and the 'all' option keeps every tags (useful if you only want to convert formats). If an integer is given, at most this number of tags will be kept at the same location. Default: auto">
                <option value="auto" selected="true">auto</option>
                <option value="all">all</option>
                <option value="user">user defined</option>
            </param>
            <when value="user">
                <param name="user_keepdup" type="integer" value="10" label="Keep at most this number of tags"/>
            </when>
            <when value="all"/>
            <when value="auto"/>
        </conditional>
    </inputs>
    <outputs>
        <data name="outfile" format="bed" label="${tool.name} on ${on_string}" />
    </outputs>
    <tests>
        <test>
            <param name="infile" value="ChIP_200K_w_dups.bed" ftype="bed"/>
            <param name="pvalue" value="1e-5"/>
            <param name="keep_dup_options_selector" value="auto"/>
            <param name="effective_genome_size_options_selector" value="3300000000"/>
            <output name="outfile" file="filterdup_on_ChIP_200K_w_dups.bed"/>
        </test>
    </tests>
    <help>
**What it does**

Remove duplicate reads at the same position, then convert acceptable format to BED format.
filterdup tool from macs2

@citation@
  </help>
</tool>
