<tool id="lofreq_indelqual" name="Insert indel qualities" version="@TOOL_VERSION@+galaxy1" profile="18.01">
    <description>into a BAM file</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements" />
    <command detect_errors="exit_code"><![CDATA[
        #if $strategy.selector == 'dindel'
            #set $reference_source = $strategy.reference_source
            @PREPARE_REF@
        #end if
        lofreq indelqual
        #if $strategy.selector == 'dindel'
            --dindel
            --ref $reference_fasta_fn
        #else
            #if $strategy.deletions
                --uniform $strategy.insertions,$strategy.deletions
            #else
                --uniform $strategy.insertions
            #end if
        #end if
        -o output.bam $reads
    ]]></command>
    <inputs>
        <param type="data" name="reads" format="bam" label="Reads" />
        <conditional name="strategy">
            <param name="selector" type="select" label="Indel calculation approach">
                <option value="uniform">Uniform</option>
                <option value="dindel">Dindel</option>
            </param>
            <when value="uniform">
                <param name="insertions" type="integer" value="30" label="Indel quality to add" help="Should probably not be left at the default value" />
                <param name="deletions" type="integer" optional="true" label="Separate deletion quality" help="Leave blank to use the same values for insertions and deletions" />
            </when>
            <when value="dindel">
                <expand macro="reference_interface" />
            </when>
        </conditional>
    </inputs>
    <outputs>
        <data name="output" format="bam" from_work_dir="output.bam" label="Add indel qualities to data ${reads.dataset.hid}" />
    </outputs>
    <tests>
        <test>
            <param name="reads" ftype="bam" value="lofreq-in1.bam" />
            <param name="selector" value="uniform" />
            <param name="insertions" value="20" />
            <param name="deletions" value="30" />
            <output name="output" file="indelqual-out1.bam" ftype="bam" />
        </test>
        <test>
            <param name="reads" ftype="bam" value="lofreq-in1.bam" />
            <param name="selector" value="dindel" />
            <param name="ref_selector" value="history" />
            <param name="ref" ftype="fasta" value="pBR322.fa" />
            <output name="output" file="indelqual-out2.bam" ftype="bam" />
        </test>
        <test>
            <param name="reads" ftype="bam" value="lofreq-in1.bam" />
            <param name="selector" value="uniform" />
            <param name="insertions" value="20" />
            <output name="output" file="indelqual-out3.bam" ftype="bam" />
        </test>
    </tests>
    <help><![CDATA[
Insert indel qualities into BAM file

The tool has two modes: 'uniform' and 'dindel':
    - 'uniform' will assign a given value uniformly, whereas
    - 'dindel' will insert indel qualities based on Dindel.

Both will overwrite any existing values. Do not realign your BAM file afterwards!
    ]]></help>
    <expand macro="citations">
        <citation type="doi">10.1101/gr.112326.110</citation>
    </expand>
</tool>
