<tool id="lofreq_viterbi" name="Realign reads" version="@WRAPPER_VERSION@0" python_template_version="3.5">
    <description>with LoFreq viterbi</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements" />
    <command detect_errors="exit_code"><![CDATA[
        @PREPARE_REF@
        lofreq viterbi --ref '$reference_fasta_fn' --out - $keepflags --defqual $defqual '$reads' | samtools sort - -O BAM -o '$realigned'
    ]]></command>
    <inputs>
        <param name="reads" type="data" format="bam" label="Reads to realign" />
        <expand macro="reference_interface" />
        <param argument="--keepflags" type="boolean" truevalue="--keepflags" label="Don't delete flags MC, MD, NM, and A" help="These flags are all prone to changing during realignment" />
        <param argument="--defqual" type="integer" value="-1" label="Quality to assume for all bases with BQ2" />
    </inputs>
    <outputs>
        <data name="realigned" format="bam" label="${tool.name} on ${on_string}: Realigned reads" />
    </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="realigned" file="viterbi-out1.bam" />
        </test>
        <test>
            <param name="reads" ftype="bam" value="lofreq-in1.bam" />
            <param name="ref_selector" value="history" />
            <param name="keepflags" value="true" />
            <param name="ref" ftype="fasta" value="pBR322.fa" />
            <output name="realigned" file="viterbi-out2.bam" />
        </test>
    </tests>
    <help><![CDATA[
Usage: lofreq viterbi [options] in.bam

Options:
    -f | --ref FILE     Indexed reference fasta file [null]
    -k | --keepflags    Don't delete flags MC, MD, NM and A, which are all prone to change during realignment.
    -q | --defqual INT  Assume INT as quality for all bases with BQ2. Default (=-1) is to use median quality of bases in read.
    -o | --out FILE     Output BAM file [- = stdout = default]
    --verbose      Be verbose

NOTE: Output BAM file will (likely) be unsorted (use samtools sort, e.g. lofreq viterbi ... | samtools sort -')

    ]]></help>
    <expand macro="citations" />
</tool>