<?xml version="1.0"?>
<tool id="hyphy_fade" name="HyPhy-FADE" version="@VERSION@+galaxy1">
    <description>: FUBAR* Approach to Directional Evolution (*Fast
    Unconstrained Bayesian Approximation)</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <command detect_errors="exit_code"><![CDATA[
        ln -s '$input_file' fade_input.fa &&
        ln -s '$input_nhx' fade_input.nhx &&
        hyphy fade
            --alignment ./fade_input.fa
            --tree ./fade_input.nhx
            --branches '$branches'
            --model '$model'
            --method '$posteriorEstimationMethod'
            --grid '$grid_points'
            --concentration_parameter '$concentration'
            #if $posteriorEstimationMethod != "Metropolis-Hastings"
                --chains '$mcmc'
                --chain-length '$chain_length'
                --burn-in '$samples'
                --samples '$samples_per_chain'
            #end if
            --output '$fade_output'
            > '$fade_log'
    ]]></command>
    <inputs>
        <param name="input_file" type="data" format="fasta" label="Input amino acid FASTA file"/>
        <param name="input_nhx" type="data" format="nhx" label="Input rooted newick file"/>
        <expand macro="branches"/>
        <expand macro="substitution" />
        <param name="grid_points" type="integer" value="20" min="5" max="50" label="Grid points"/>
        <param name="mcmc" type="integer" value="5" min="2" max="20" label="Number of MCMC chains"/>
        <param name="chain_length" type="integer" value="2000000" min="500000" max="50000000" label="Length of each chain"/>
        <param name="samples" type="integer" value="1000000" min="100000" max="1900000" label="Samples to use for burn-in"/>
        <param name="samples_per_chain" type="integer" value="100" min="50" max="1000000" label="Samples to draw from each chain"/>
        <param name="concentration" type="float" value="0.5" min="0.001" max="1" label="Concentration parameter of the Dirichlet prior"/>
        <expand macro="branches"/>
        <param name="posteriorEstimationMethod" type="select" label="Posterior estimation method">
            <option value="Variational-Bayes">Metropolis-Hastings - Full
            Metropolis-Hastings MCMC algorithm (slowest, original 2013
            paper implementation)</option>
            <option value="Collapsed-Gibbs">Collapsed Gibbs - Collapsed Gibbs sampler
            (intermediate speed)</option>
            <option value="Metropolis-Hastings">Variational Bayes - 0-th order Variational
            Bayes approximations (fastest, recommended default)</option>
        </param>
    </inputs>
    <outputs>
        <data name="fade_log" format="txt"/>
        <data name="fade_output" format="hyphy_results.json" />
    </outputs>
    <tests>
        <test>
            <param name="input_file" ftype="fasta" value="fade-in1.fa"/>
            <param name="input_nhx" ftype="nhx" value="fade-in1.nhx"/>
            <output name="fade_output" file="fade-out1.json" compare="sim_size"/>
        </test>
    </tests>
    <help><![CDATA[
FADE (FUBAR Approach to Directional Evolution) uses the same underlying algorithmic advances as impletented in FUBAR to apply Baysian MCMC accounting of parameter uncertiantiy to detect sites evolving under directional evolution in protien alignments.

See the online documentation_ for more information.

.. _documentation: http://hyphy.org/methods/selection-methods/#fade
    ]]></help>
    <expand macro="citations">
        <citation type="doi">10.1093/molbev/msv022</citation>
    </expand>
</tool>
