<macros>
    <token name="@WRAPPER_VERSION@">@TOOL_VERSION@+galaxy</token>
    <token name="@TOOL_VERSION@">2.1.3.1</token>
    <xml name="requirements">
        <requirements>
            <requirement type="package" version="@TOOL_VERSION@">lofreq</requirement>
            <yield/>
        </requirements>
    </xml>
    <xml name="citations">
        <citations>
            <citation type="doi">10.1093/nar/gks918</citation>
            <yield />
        </citations>
    </xml>
    <token name="@PREPARE_REF@"><![CDATA[
        #if str($reference_source.ref_selector) == 'history':
            #set $reference_fasta_fn = 'reference.fa'
            ln -s '$reference_source.ref' $reference_fasta_fn &&
            lofreq faidx $reference_fasta_fn 2>&1 || echo "Error running samtools faidx for indexing fasta reference for lofreq" >&2 &&
        #else
            #set $reference_fasta_fn = str($reference_source.ref.fields.path)
        #end if
    ]]></token>
    <xml name="reference_interface">
        <conditional name="reference_source">
            <param name="ref_selector" type="select"
            label="Choose the source for the reference genome">
                <option value="cached">Locally cached</option>
                <option value="history">History</option>
            </param>
            <when value="cached">
                <param argument="--ref" type="select"
                label="Reference genome">
                    <options from_data_table="fasta_indexes">
                        <filter type="data_meta" column="dbkey" key="dbkey" ref="reads" />
                        <validator type="no_options" message="A built-in reference genome is not available for the build associated with the selected input file" />
                    </options>
                </param>
            </when>
            <when value="history">
                <param argument="--ref" type="data" format="fasta" label="Reference" help="Reference sequence" />
            </when>
        </conditional>
    </xml>
    <xml name="handle_existing_alnqual">
        <conditional name="alnqual_choice">
            <param name="alnquals_to_use" type="select"
            label="Use the following alignment quality scores">
                <option value="">Base and indel alignment qualities (BAQ and IDAQ)</option>
                <option value="-A">Only base alignment qualities (BAQ)</option>
                <option value="-B">Only indel alignment qualities (IDAQ)</option>
            </param>
            <when value="-B">
                <param name="extended_baq" type="hidden" value="" />
            </when>
            <when value="">
                <param argument="-e" name="extended_baq" type="boolean" checked="true" truevalue="" falsevalue="-e"
                label="If BAQ needs to be computed, calculate extended BAQ?" />
            </when>
            <when value="-A">
                <param argument="-e" name="extended_baq" type="boolean" checked="true" truevalue="" falsevalue="-e"
                label="If BAQ needs to be computed, calculate extended BAQ?" />
            </when>
        </conditional>
    </xml>
    <xml name="handle_alnqual" token_mode="Use">
        <conditional name="alnqual_choice">
            <param name="alnquals_to_use" type="select"
            label="@MODE@ the following alignment quality scores">
                <option value="">Base and indel alignment qualities (BAQ and IDAQ)</option>
                <option value="-A">Only base alignment qualities (BAQ)</option>
                <option value="-B">Only indel alignment qualities (IDAQ)</option>
            </param>
            <when value="-B">
                <param name="extended_baq" type="hidden" value="" />
            </when>
            <when value="">
                <param argument="-e" name="extended_baq" type="boolean" checked="true" truevalue="" falsevalue="-e"
                label="Use extended BAQ?" />
            </when>
            <when value="-A">
                <param argument="-e" name="extended_baq" type="boolean" checked="true" truevalue="" falsevalue="-e"
                label="Use extended BAQ?" />
            </when>
        </conditional>
    </xml>
</macros>
