<tool id="lofreq_alnqual" name="Add LoFreq alignment quality scores" version="@WRAPPER_VERSION@0">
    <description>to aligned read SAM/BAM records</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements" />
    <command detect_errors="exit_code"><![CDATA[
        @PREPARE_REF@
        lofreq alnqual -b ${alnqual_choice.extended_baq} ${alnqual_choice.alnquals_to_use} $recompute_all '$reads' '$reference_fasta_fn' > '$output'
    ]]></command>
    <inputs>
        <param type="data" name="reads" format="bam" label="Reads" />
        <expand macro="reference_interface" />
        <expand macro="handle_alnqual" mode="Add" />
        <param argument="-r" name="recompute_all" type="boolean" truevalue="-r" falsevalue=""
        label="Overwrite exisitng values with newly computed ones" />
    </inputs>
    <outputs>
        <data name="output" format="bam" label="${tool.name} to ${on_string}" />
    </outputs>
    <tests>
        <test>
            <param name="reads" ftype="bam" value="lofreq-in1.bam" />
            <param name="ref_selector" value="history" />
            <param name="ref" ftype="fasta" value="pBR322.fa" />
            <output name="output" file="alnqual-out1.bam" />
        </test>
        <test>
            <param name="reads" ftype="bam" value="lofreq-in1.bam" />
            <param name="ref_selector" value="history" />
            <param name="ref" ftype="fasta" value="pBR322.fa" />
            <conditional name="alnqual_choice">
                <param name="alnquals_to_use" value="-B" />
            </conditional>
            <output name="output" file="alnqual-out2.bam" />
        </test>
        <test>
            <param name="reads" ftype="bam" value="lofreq-in1.bam" />
            <param name="ref_selector" value="history" />
            <param name="ref" ftype="fasta" value="pBR322.fa" />
            <conditional name="alnqual_choice">
                <param name="alnquals_to_use" value="-A" />
            </conditional>
            <output name="output" file="alnqual-out3.bam" />
        </test>
        <test>
            <param name="reads" ftype="bam" value="lofreq-in1.bam" />
            <param name="ref_selector" value="history" />
            <param name="ref" ftype="fasta" value="pBR322.fa" />
            <conditional name="alnqual_choice">
                <param name="extended_baq" value="false" />
            </conditional>
            <output name="output" file="alnqual-out4.bam" />
        </test>
        <test>
            <param name="reads" ftype="bam" value="lofreq-in1.bam" />
            <param name="ref_selector" value="history" />
            <param name="ref" ftype="fasta" value="pBR322.fa" />
            <param name="recompute" value="true" />
            <output name="output" file="alnqual-out5.bam" />
        </test>
    </tests>
    <help><![CDATA[
lofreq alnqual: add base- and indel-alignment qualities (BAQ, IDAQ) to
aligned read records

.. class:: infomark

   **What it does**

This tool can compute base- and/or indel-alignment quality scores for aligned
reads in SAM/BAM format and store these scores under the custom tags ``lb``
(for the base alignment qualities, ``ai`` (insertion alignment qualities) and
``ad`` (deletion alignment qualities), which it will add to its output BAM.

These tags and their scores can be reused by LoFreq call, which can
incorporate them into its model for variant quality calculation.

.. class:: warning

   **Do not realign** your reads after adding alignment qualities to them since
   the scores would not be updated in the process!

Notes:

- While LoFreq call can optionally calculate the exact same scores on the fly
  if needed, having the scores added to the aligned read records is going to
  save computation time with repeated variant calling from the same input data.

- The base alignment quality scores have the same meaning as in samtools, but
  are expressed as absolute scores, not as base quality offsets like with the
  `BQ` tag generated by samtools.

- `ai` and `ad` tags, if requested, will only be added to reads containing
  insertions/deletions.
    ]]></help>
    <expand macro="citations" />
</tool>
