<tool id="iqtree" name="IQ-TREE" version="@TOOL_VERSION@+@VERSION_SUFFIX@" >
    <description>Phylogenomic / evolutionary tree construction from multiple sequences</description>
    <macros>
        <token name="@VERSION_SUFFIX@">galaxy2</token>
        <import>iqtree_macros.xml</import>
    </macros>
    <expand macro="requirements" />
    <command detect_errors="exit_code"><![CDATA[
iqtree
    --prefix PREF
    #if $general_options.short_alignments:
        -T 1
    #else:
        -T \${GALAXY_SLOTS:-10}
    #end if
    --redo

## file
#if $general_options.s
    -s '$general_options.s'
#end if

#if $general_options.o
    -o '$general_options.o'
#end if

## file
#if $general_options.t
    -t '$general_options.t'
    $tree_parameters.constructing_consensus.contree
    $tree_parameters.constructing_consensus.connet
    #if str($tree_parameters.constructing_consensus.burnin) != ''
        --burnin '$tree_parameters.constructing_consensus.burnin'
    #end if

    ## file
    #if $tree_parameters.constructing_consensus.support
        --support '$tree_parameters.constructing_consensus.support'
    #end if

    #if str($tree_parameters.constructing_consensus.suptag) != ''
        --suptag '$tree_parameters.constructing_consensus.suptag'
    #end if

    ## file
    #if $tree_parameters.computing_robinson_foulds.tree_dist_all
        $tree_parameters.computing_robinson_foulds.tree_dist_all
        --tree-dist $tree_parameters.computing_robinson_foulds.tree_dist
        --tree-dist2 $tree_parameters.computing_robinson_foulds.tree_dist2
    #end if
    $tree_parameters.ancestral_state.ancestral
    #if $tree_parameters.ancestral_state.asr_min:
        --asr-min $tree_parameters.ancestral_state.asr_min
    #end if
    #if $tree_parameters.concordance_factor.gcf:
        --gcf '$tree_parameters.concordance_factor.gcf'
    #end if
    #if $tree_parameters.concordance_factor.scf:
        --scf '$tree_parameters.concordance_factor.scf'
    #end if
    $tree_parameters.concordance_factor.df_tree
    $tree_parameters.concordance_factor.cf_verbose
    $tree_parameters.concordance_factor.cf_quartet
    $tree_parameters.symmetry_test.symtest
    $tree_parameters.symmetry_test.symtest_remove_bad
    $tree_parameters.symmetry_test.symtest_remove_good
    $tree_parameters.symmetry_test.symtest_keep_zero
    #if $tree_parameters.symmetry_test.symtest_pval:
        --symtest-pval $tree_parameters.symmetry_test.symtest_pval
    #end if
    #if $tree_parameters.symmetry_test.symtest_type:
        --symtest-type $tree_parameters.symmetry_test.symtest_type
    #end if
#end if

## date options
#if str($time_tree.date_source.select_source) == 'dataset':
    #if $time_tree.date_source.date:
        --date '$time_tree.date_source.date'
    #end if
#elif str($time_tree.date_source.select_source) == 'input':
    --date TAXNAME
    #if str($time_tree.date_source.date_tip) != '':
        --date-tip '$time_tree.date_source.date_tip'
    #end if
    #if str($time_tree.date_source.date_root) != '':
        --date-root '$time_tree.date_source.date_root'
    #end if
    #if str($time_tree.date_source.date_ci) != '':
        --date-ci '$time_tree.date_source.date_ci'
    #end if
    #if str($time_tree.date_source.clock_sd) != '':
        --clock-sd '$time_tree.date_source.clock_sd'
    #end if
    #if str($time_tree.date_source.date_outlier) != '':
        --date-outlier '$time_tree.date_source.date_outlier'
    #end if
    #if str($time_tree.date_source.date_options) != '':
        --date-options '$time_tree.date_source.date_options'
    #end if
    --dating LSD
    $time_tree.date_source.date_no_outgroup
#end if

## file
#if str($general_options.epsilon) != ''
    --epsilon '$general_options.epsilon'
#end if

#if str($general_options.seed) != ''
    --seed '$general_options.seed'
#end if

$general_options.keep_ident
$general_options.safe

#if str($likelihood_mapping.lmap) != ''
    --lmap '$likelihood_mapping.lmap'
#end if

## file
#if $likelihood_mapping.lmclust
    --lmclust '$likelihood_mapping.lmclust'
#end if

$likelihood_mapping.quartetlh

#if $modelling_parameters.automatic_model.cond_model.opt_custommodel:
    -m '$modelling_parameters.automatic_model.cond_model.m'
#else:
    #if str($modelling_parameters.automatic_model.cond_model.m) != ''
        #if $modelling_parameters.automatic_model.cond_model.additional_models:
            -m '$modelling_parameters.automatic_model.cond_model.m${$modelling_parameters.automatic_model.cond_model.additional_models}'
        #else:
            -m '$modelling_parameters.automatic_model.cond_model.m'
        #end if
    #end if
#end if

#if str($modelling_parameters.automatic_model.merge_strategy.merge) != 'none':
    --merge $modelling_parameters.automatic_model.merge_strategy.merge
    #if str($modelling_parameters.automatic_model.merge_strategy.merge) == 'rcluster':
        --rcluster $modelling_parameters.automatic_model.merge_strategy.rcluster
    #end if
    #if str($modelling_parameters.automatic_model.merge_strategy.merge) == 'rclusterf':
        --rclusterf $modelling_parameters.automatic_model.merge_strategy.rclusterf
    #end if
    #if str($modelling_parameters.automatic_model.merge_strategy.merge) in ['rcluster', 'rclusterf']:
        --rcluster-max $modelling_parameters.automatic_model.merge_strategy.rcluster_max
    #end if
#end if

#if str($modelling_parameters.automatic_model.mset) != ''
    --mset '$modelling_parameters.automatic_model.mset'
#end if

#if str($modelling_parameters.automatic_model.msub) != ''
    --msub '$modelling_parameters.automatic_model.msub'
#end if

#if str($modelling_parameters.automatic_model.mfreq) != ''
    --mfreq '$modelling_parameters.automatic_model.mfreq'
#end if

#if str($modelling_parameters.automatic_model.mrate) != ''
    --mrate '$modelling_parameters.automatic_model.mrate'
#end if

#if str($modelling_parameters.automatic_model.cmin) != ''
    --cmin '$modelling_parameters.automatic_model.cmin'
#end if

#if str($modelling_parameters.automatic_model.cmax) != ''
    --cmax '$modelling_parameters.automatic_model.cmax'
#end if

#if str($modelling_parameters.automatic_model.merit) != ''
    --merit '$modelling_parameters.automatic_model.merit'
#end if

$modelling_parameters.automatic_model.mtree

#if str($modelling_parameters.automatic_model.madd) != ''
    --madd '$modelling_parameters.automatic_model.madd'
#end if

## file
#if $modelling_parameters.automatic_model.mdef
    --mdef '$modelling_parameters.automatic_model.mdef'
#end if

$modelling_parameters.automatic_model.modelomatic
$modelling_parameters.specifying_substitution.mix_opt

#if str($modelling_parameters.rate_heterogeneity.alpha_min) != ''
    --alpha-min '$modelling_parameters.rate_heterogeneity.alpha_min'
#end if

$modelling_parameters.rate_heterogeneity.gamma_median

#if str($modelling_parameters.rate_heterogeneity.i) != ''
    -i '$modelling_parameters.rate_heterogeneity.i'
#end if

$modelling_parameters.rate_heterogeneity.opt_gamma_inv
$modelling_parameters.rate_heterogeneity.rate

#if str($modelling_parameters.partition_model.model_selection.model) != 'none':
    -$modelling_parameters.partition_model.model_selection.model '$modelling_parameters.partition_model.model_selection.model_file'
    #if str($modelling_parameters.partition_model.model_selection.subsample) != '':
        --subsample $modelling_parameters.partition_model.model_selection.subsample
    #end if
    #if str($modelling_parameters.partition_model.model_selection.subsample_seed) != '':
        --subsample-seed $modelling_parameters.partition_model.model_selection.subsample_seed
    #end if
#end if

## file
#if $modelling_parameters.site_specific_frequency.tree_freq
    --tree-freq '$modelling_parameters.site_specific_frequency.tree_freq'
#end if

#if str($modelling_parameters.site_specific_frequency.site_freq) != ''
    --site-freq '$modelling_parameters.site_specific_frequency.site_freq'
#end if

$modelling_parameters.site_specific_frequency.freq_max

#if str($tree_parameters.tree_search.ninit) != ''
    --ninit '$tree_parameters.tree_search.ninit'
#end if

#if str($tree_parameters.tree_search.ntop) != ''
    --ntop '$tree_parameters.tree_search.ntop'
#end if

#if str($tree_parameters.tree_search.nbest) != ''
    --nbest '$tree_parameters.tree_search.nbest'
#end if

#if str($tree_parameters.tree_search.nstop) != ''
    --nstop '$tree_parameters.tree_search.nstop'
#end if

#if str($tree_parameters.tree_search.n) != ''
    -n '$tree_parameters.tree_search.n'
#end if

#if str($tree_parameters.tree_search.radius) != ''
    --radius '$tree_parameters.tree_search.radius'
#end if

#if str($tree_parameters.tree_search.perturb) != ''
    --perturb '$tree_parameters.tree_search.perturb'
#end if

$tree_parameters.tree_search.allnni
$tree_parameters.tree_search.tree_fix
$tree_parameters.tree_search.fast
$tree_parameters.tree_search.polytomy
$tree_parameters.tree_search.treels
$tree_parameters.tree_search.show_lh
$tree_parameters.tree_search.terrace

## file
#if $tree_parameters.tree_search.g
    -g '$tree_parameters.tree_search.g'
#end if

#if str($tree_parameters.single_branch.alrt) != ''
    --alrt '$tree_parameters.single_branch.alrt'
#end if

$tree_parameters.single_branch.abayes

#if str($tree_parameters.single_branch.lbp) != ''
    --lbp '$tree_parameters.single_branch.lbp'
#end if

## file
#if $tree_parameters.tree_topology.trees
    --trees '$tree_parameters.tree_topology.trees'
#end if

#if str($tree_parameters.tree_topology.test) != ''
    --test '$tree_parameters.tree_topology.test'
#end if

$tree_parameters.tree_topology.test_weight
$tree_parameters.tree_topology.test_au

#if str($tree_parameters.constructing_consensus.sup_min) != ''
    --sup-min '$tree_parameters.constructing_consensus.sup_min'
#end if


#if str($tree_parameters.generating_random.r) != ''
    -r '$tree_parameters.generating_random.r'
#end if

#if $tree_parameters.generating_random.rand
    $tree_parameters.generating_random.rand
#end if

#if str($tree_parameters.generating_random.branch_min) != '' and str($tree_parameters.generating_random.branch_mean) != '' and str($tree_parameters.generating_random.branch_max) != ''
    --rlen $tree_parameters.generating_random.branch_min $tree_parameters.generating_random.branch_mean $tree_parameters.generating_random.branch_max
#end if

#if str($bootstrap_parameters.ultrafast_bootstrap.ufboot) != ''
    --ufboot '$bootstrap_parameters.ultrafast_bootstrap.ufboot'
#end if

#if str($bootstrap_parameters.ultrafast_bootstrap.ufjack) != ''
    --ufjack '$bootstrap_parameters.ultrafast_bootstrap.ufjack'
#end if

#if str($bootstrap_parameters.ultrafast_bootstrap.jack_prop) != ''
    --jack-prop '$bootstrap_parameters.ultrafast_bootstrap.jack_prop'
#end if

#if str($bootstrap_parameters.ultrafast_bootstrap.sampling) != ''
    --sampling '$bootstrap_parameters.ultrafast_bootstrap.sampling'
#end if

$bootstrap_parameters.ultrafast_bootstrap.boot_trees
$bootstrap_parameters.ultrafast_bootstrap.wbtl

#if str($bootstrap_parameters.ultrafast_bootstrap.nmax) != ''
    --nmax '$bootstrap_parameters.ultrafast_bootstrap.nmax'
#end if

#if str($bootstrap_parameters.ultrafast_bootstrap.nstep) != ''
    --nstep '$bootstrap_parameters.ultrafast_bootstrap.nstep'
#end if

#if str($bootstrap_parameters.ultrafast_bootstrap.bcor) != ''
    --bcor '$bootstrap_parameters.ultrafast_bootstrap.bcor'
#end if

#if str($bootstrap_parameters.ultrafast_bootstrap.beps) != ''
    --beps '$bootstrap_parameters.ultrafast_bootstrap.beps'
#end if

$bootstrap_parameters.ultrafast_bootstrap.bnni

#if str($bootstrap_parameters.nonparametric_bootstrap.boot) != ''
    --boot '$bootstrap_parameters.nonparametric_bootstrap.boot'
#end if

#if str($bootstrap_parameters.nonparametric_bootstrap.jack) != ''
    --jack '$bootstrap_parameters.nonparametric_bootstrap.jack'
#end if

#if str($bootstrap_parameters.nonparametric_bootstrap.jack_prop) != ''
    --jack-prop '$bootstrap_parameters.nonparametric_bootstrap.jack_prop'
#end if

$bootstrap_parameters.nonparametric_bootstrap.bcon
$bootstrap_parameters.nonparametric_bootstrap.bonly
$bootstrap_parameters.nonparametric_bootstrap.tbe

#if str($miscellaneous_options.fconst) != ''
    --fconst '$miscellaneous_options.fconst'
#end if
]]>
    </command>
    <inputs>
        <section name="general_options" expanded="true" title="General options">
            <param argument="-s" type="data" format="txt,fasta,phylip,nex,clustal,msf" optional="true" label="Specify input alignment file in PHYLIP, FASTA, NEXUS, CLUSTAL or MSF format."/>
            <param argument="-o" type="text" optional="true" label="Comma-separated list of taxons to output">
                <expand macro="sanitize_query" />
            </param>

            <param type="boolean" name="short_alignments" label="Short alignments" help="IQ-TREE will fail if given too many threads on input data that consists of short alignments, this option will force the use of a single thread." />
            <param argument="--seqtype" type="select" label="Specify sequence type as either of DNA, AA, BIN, MORPH, CODON or NT2AA for DNA, amino-acid, binary, morphological, codon or DNA-to-AA-translated sequences">
                <help><![CDATA[
Note that --seqtype CODON is always necessary when using codon models and you also need to specify a genetic code like this if differed from the standard genetic code.
<br/><i>-st</i> NT2AA tells IQ-TREE to translate protein-coding DNA into AA sequences and then subsequent analysis will work on the AA sequences. You can also use a genetic code like --seqtype NT2AA5 for the Invertebrate Mitochondrial Code (see genetic code table).]]>
                </help>
                <option value="DNA">DNA</option>
                <option value="AA">AA</option>
                <option value="BIN">BIN</option>
                <option value="MORPH">MORPH</option>
                <option value="CODON">CODON</option>
                <option value="NT2AA">NT2AA</option>
            </param>
            <param argument="-t" type="data" format="nhx" optional="true" label="Specify a file containing starting tree for tree search"/>
            <param argument="--seed" type="integer" optional="true" label="Specify a random number seed to reproduce a previous run (leave blank to randomize)"/>
            <param argument="--keep-ident" type="boolean" truevalue="--keep-ident" falsevalue="" checked="false" label="Keep identical sequences in the alignment" help="By default: IQ-TREE will remove them during the analysis and add them in the end."/>
            <param argument="--epsilon" type="float" optional="true" min="0" max="1" label="Likelihood epsilon for parameter estimate" />
            <param argument="--safe" type="boolean" truevalue="--safe" falsevalue="" checked="false" label="Turn on safe numerical mode to avoid numerical underflow for large data sets with many sequences (typically in the order of thousands)" help="This mode is automatically turned on when having more than 2000 sequences."/>
        </section>
        <section name="time_tree" expanded="false" title="Time Tree Reconstruction">
            <conditional name="date_source">
                <param name="select_source" type="select" label="Source of date information">
                    <option value="none">Skip time tree reconstruction</option>
                    <option value="dataset">Text file</option>
                    <option value="input">Derive from input</option>
                </param>
                <when value="none" />
                <when value="input" />
                <when value="dataset">
                    <param argument="--date" type="data" format="txt,tabular" optional="true" label="File containing dates of tips or ancestral nodes" />
                </when>
            </conditional>
            <param argument="--date-tip" type="text" optional="true" label="Tip dates as a real number or YYYY-MM-DD">
                <expand macro="sanitize_query" />
            </param>
            <param argument="--date-root" type="text" optional="true" label="Root date as a real number or YYYY-MM-DD">
                <expand macro="sanitize_query" />
            </param>
            <param argument="--date-ci" type="integer" optional="true" label="Number of replicates to compute confidence interval" />
            <param argument="--clock-sd" type="float" optional="true" label="Standard-deviation for lognormal relaxed clock" />
            <param argument="--date-no-outgroup" type="boolean" truevalue="--date-no-outgroup" falsevalue="" label="Exclude outgroup from time tree" />
            <param argument="--date-outlier" type="integer" optional="true" label="Z-score cutoff to remove outlier tips/nodes" />
            <param argument="--date-options" type="text" optional="true" label="Extra options passing directly to LSD2">
                <expand macro="sanitize_query" />
            </param>
        </section>
        <section name="likelihood_mapping" expanded="False" title="Likelihood mapping analysis">
            <param argument="--lmap" type="integer" optional="true" label="Specify the number of quartets to be randomly drawn" help="If you specify -lmap ALL, all unique quartets will be drawn, instead."/>
            <param argument="--lmclust" type="data" format="txt" optional="true" label="Specify a NEXUS file containing taxon clusters (see below for example) for quartet mapping analysis."/>
            <param argument="--quartetlh" type="boolean" truevalue="--quartetlh" falsevalue="" checked="false" label="Write quartet log-likelihoods into .lmap.quartetlh file (typically not needed)."/>
        </section>
        <section name="modelling_parameters" title="Modelling Parameters">
            <section name="automatic_model" expanded="False" title="Automatic model selection">
                <conditional name="cond_model" >
                    <param name="opt_custommodel" type="boolean" checked="false" label="Use Custom Model" help="See http://www.iqtree.org/doc/Substitution-Models"/>
                    <when value="true">
                        <param argument="-m" type="text" label="Model">
                            <expand macro="sanitize_query"
                                    validinitial="string.ascii_uppercase,string.digits,string.punctuation" />
                        </param>
                    </when>
                    <when value="false">
                        <param argument="-m" type="select" label="Perform standard model selection like jModelTest (for DNA) and ProtTest (for protein)" >
                            <help><![CDATA[
<b>Note:</b> Only <code>TEST</code> and custom models that do not rely on <code>MF</code> can be used in conjunction with bootstrap parameters (-b)<br/><br/>
IQ-TREE also works for codon, binary and morphogical data.
<table>
    <tr>
        <td><i>TESTONLY</i></td>
        <td>Perform standard model selection like jModelTest (for DNA) and ProtTest (for protein). Moreover, IQ-TREE also works for codon, binary and morphogical data.</td>
    </tr>
    <tr>
        <td><i>TEST</i></td>
        <td>Like -m TESTONLY but immediately followed by tree reconstruction using the best-fit model found. So this performs both model selection and tree inference within a single run.</td>
    </tr>
    <tr>
        <td><i>MF</i></td>
        <td>Best-fit model selection without tree reconstruction.</td>
    </tr>
    <tr>
        <td><i>MFP</i></td>
        <td>Extended model selection with FreeRate heterogeneity immediately followed by tree inference.</td>
    </tr>
</table>
]]>
                            </help>
                            <option value="" selected="true">(None)</option>
                            <option value="TESTONLY">Standard model selection</option>
                            <option value="TEST">Standard model selection followed by tree inference</option>
                            <option value="MF">Extended model selection with FreeRate heterogeneity</option>
                            <option value="MFP">Extended model selection followed by tree inference</option>
                        </param>
                        <param name="additional_models" type="text" optional="true" label="Additional model specifications" help="See http://www.iqtree.org/doc/Substitution-Models">
                            <expand macro="sanitize_query" />
                        </param>
                    </when>
                </conditional>
                <conditional name="merge_strategy">
                    <param argument="--merge" type="select" label="Merge partitions">
                        <option value="none">Do not merge</option>
                        <option value="rclusterf">Merge using rcluster relaxed algorithm</option>
                        <option value="rcluster">Merge using rcluster algorithm</option>
                        <option value="greedy">Merge using greedy algorithm</option>
                    </param>
                    <when value="none" />
                    <when value="greedy" />
                    <when value="rcluster">
                        <param argument="--rcluster" type="integer" optional="true" label="Specify the percentage for the relaxed clustering algorithm (Lanfear et al., 2014)" help="This is similar to --rcluster-percent option of PartitionFinder. For example, giving the value 10 only the top 10% partition schemes are considered to save computations." />
                        <param argument="--rcluster-max" type="integer" optional="true" label="Max number of partition pairs" />
                    </when>
                    <when value="rclusterf">
                        <param argument="--rclusterf" type="integer" optional="true" label="Specify the percentage for the relaxed clustering algorithm (Lanfear et al., 2014)" help="This is similar to --rcluster-percent option of PartitionFinder. For example, giving the value 10 only the top 10% partition schemes are considered to save computations." />
                        <param argument="--rcluster-max" type="integer" optional="true" label="Max number of partition pairs" />
                    </when>
                </conditional>
                <param argument="--mset" type="text" optional="true" label="Specify the name of a program (raxml, phyml or mrbayes) to restrict to only those models supported by the specified program" help="Alternatively, one can specify a comma-separated list of base models. For example, -mset WAG,LG,JTT will restrict model selection to WAG, LG, and JTT instead of all 18 AA models to save computations.">
                    <expand macro="sanitize_query"
                    validinitial="string.ascii_letters,string.punctuation" />
                </param>
                <param argument="--msub" type="select" label="Specify either nuclear, mitochondrial, chloroplast or viral to restrict to those AA models designed for specified source." help="">
                    <option value="nuclear">nuclear</option>
                    <option value="mitochondrial">mitochondrial</option>
                    <option value="chloroplast">chloroplast</option>
                    <option value="viral">viral</option>
                </param>
                <param argument="--mfreq" type="text" optional="true" label="Specify a comma-separated list of frequency types for model selection" >
                    <expand macro="sanitize_query"
                    validinitial="string.ascii_uppercase,string.digits,x,string.punctuation" />
                </param>
                <param argument="--mrate" type="text" optional="true" label="Specify a comma-separated list of rate heterogeneity types for model selection">
                    <expand macro="sanitize_query"
                    validinitial="string.ascii_uppercase,string.punctuation" />
                </param>
                <param argument="--cmin" type="integer" value="2" optional="true" label="Specify minimum number of categories for FreeRate model"/>
                <param argument="--cmax" type="integer" value="10" optional="true" label="Specify maximum number of categories for FreeRate model"/>
                <param argument="--merit" type="select" label="Specify either AIC, AICc or BIC for the optimality criterion to apply for new procedure" help="">
                    <option value="AIC">AIC</option>
                    <option value="AICc">AICc</option>
                    <option value="BIC">BIC</option>
                </param>
                <param argument="--mtree" type="boolean" truevalue="-mtree" falsevalue="" checked="false" label="Turn on full tree search for each model considered, to obtain more accurate result"/>
                <param argument="--madd" type="text" optional="true" label="Specify a comma-separated list of mixture models to additionally consider for model selection" help="For example, -madd LG4M,LG4X to additionally include these two protein mixture models.">
                    <expand macro="sanitize_query"
                    validinitial="string.ascii_uppercase,string.digits,string.punctuation" />
                </param>
                <param argument="--mdef" type="data" format="txt" optional="true" label="Specify a NEXUS model file to define new models."/>
                <param argument="--modelomatic" type="boolean" truevalue="--modelomatic" falsevalue="" label="Find best codon/protein/DNA models" />
            </section>
            <section name="specifying_substitution" expanded="False" title="Specifying substitution models">
                <param argument="--mix-opt" type="boolean" truevalue="--mix-opt" falsevalue="" checked="false" label="Turn on optimizing weights of mixture models" help="Note that for models like LG+C20+F+G this mode is automatically turned on, but not for LG+C20+G."/>
            </section>
            <section name="rate_heterogeneity" expanded="False" title="Rate heterogeneity">
                <param argument="--alpha-min" type="text" optional="true" label="Specify the minimum Gamma shape parameter (default: estimate)">
                    <expand macro="sanitize_query" />
                </param>
                <param argument="--gamma-median" type="boolean" truevalue="--gamma-median" falsevalue="" checked="false" label="Perform the median approximation for Gamma rate heterogeneity instead of the default mean approximation (Yang, 1994)"/>
                <param argument="-i" type="text" optional="true" label="Specify the proportion of invariable sites (default: estimate)">
                    <expand macro="sanitize_query" />
                </param>
                <param argument="--opt-gamma-inv" type="boolean" truevalue="--opt-gamma-inv" falsevalue="" checked="false" label="Perform more thorough estimation for +I+G model parameters"/>
                <param argument="--rate" type="boolean" truevalue="--rate" falsevalue="" checked="false" label="Write empirical Bayesian site rates to .rate file"/>
                <param argument="--mlrate" type="boolean" truevalue="--mlrate" falsevalue="" checked="false" label="Write maximum likelihood site rates to .mlrate file"/>
            </section>
            <section name="partition_model" expanded="False" title="Partition model options">
                <conditional name="model_selection">
                    <param name="model" type="select" label="Partition model">
                        <option value="none">No partition model</option>
                        <option value="p">Edge-linked proportional partition model</option>
                        <option value="q">Edge-linked equal partition model</option>
                        <option value="Q">Edge-unlinked proportional partition model</option>
                        <option value="S">Separate tree inference</option>
                    </param>
                    <when value="none" />
                    <when value="p">
                        <param argument="-p" type="data" format="nex" optional="true" label="Partition file" />
                        <param argument="--subsample" type="integer" optional="true" label="Subsample partitions" help="Use a negative value for complement" />
                        <param argument="--subsample-seed" type="integer" optional="true" label="Subsampling random seed" help="Use a negative value for complement" />
                    </when>
                    <when value="q">
                        <param argument="-q" type="data" format="nex" optional="true" label="Partition file" />
                        <param argument="--subsample" type="integer" optional="true" label="Subsample partitions" help="Use a negative value for complement" />
                        <param argument="--subsample-seed" type="integer" optional="true" label="Subsampling random seed" help="Use a negative value for complement" />
                    </when>
                    <when value="Q">
                        <param argument="-Q" type="data" format="nex" optional="true" label="Partition file" />
                        <param argument="--subsample" type="integer" optional="true" label="Subsample partitions" help="Use a negative value for complement" />
                        <param argument="--subsample-seed" type="integer" optional="true" label="Subsampling random seed" help="Use a negative value for complement" />
                    </when>
                    <when value="S">
                        <param argument="-S" type="data" format="nex" optional="true" label="Partition file" />
                        <param argument="--subsample" type="integer" optional="true" label="Subsample partitions" help="Use a negative value for complement" />
                        <param argument="--subsample-seed" type="integer" optional="true" label="Subsampling random seed" help="Use a negative value for complement" />
                    </when>
                </conditional>
            </section>
            <section name="site_specific_frequency" expanded="False" title="Site-specific frequency model options">
                <param argument="--tree-freq" type="data" format="nhx" optional="true" label="Specify a guide tree to infer site frequency profiles."/>
                <param argument="--site-freq" type="float" optional="true" label="Specify a site frequency file, e.g" help="the .sitefreq file obtained from -ft run. This will save memory used for the first phase of the analysis."/>
                <param argument="--freq-max" type="boolean" truevalue="--freq-max" falsevalue="" checked="false" label="Switch to posterior maximum mode for obtaining site-specific profiles" help="Default: posterior mean."/>
            </section>
        </section>
        <section name="tree_parameters" title="Tree Parameters">
            <section name="tree_search" expanded="False" title="Tree search parameters">
                <param argument="-n" type="integer" optional="true" label="Skip subsequent tree search (n = 0), useful when you only want to assess the phylogenetic information of the alignment. Otherwise specify number of iterations to stop (this option overrides --nstop criterion)." />
                <param argument="--ninit" type="integer" value="100" optional="true" label="Specify number of initial parsimony trees"/>
                <param argument="--ntop" type="integer" value="20" optional="true" label="Specify number of top initial parsimony trees to optimize with ML nearest neighbor interchange (NNI) search to initialize the candidate set"/>
                <param argument="--nbest" type="integer" value="5" optional="true" label="Specify number of trees in the candidate set to maintain during ML tree search"/>
                <param argument="--nstop" type="integer" value="100" optional="true" label="Specify number of unsuccessful iterations to stop"/>
                <param argument="--radius" type="integer" value="6" optional="true" label="Specify SPR radius for the initial parsimony tree search"/>
                <param argument="--perturb" type="float" value="0.5" optional="true" label="Specify perturbation strength (between 0 and 1) for randomized NNI"/>
                <param argument="--allnni" type="boolean" truevalue="-allnni" falsevalue="" checked="false" label="Turn on more thorough and slower NNI search"/>
                <param argument="--tree-fix" type="boolean" truevalue="--tree-fix" falsevalue="" checked="false" label="Avoid computing ML pairwise distances and BIONJ tree."/>
                <param argument="-g" type="data" format="txt" optional="true" label="Specify a topological constraint tree file in NEWICK format" help="The constraint tree can be a multifurcating tree and need not to include all taxa."/>
                <param argument="--fast" type="boolean" truevalue="--fast" falsevalue="" label="Fast search to resemble FastTree" />
                <param argument="--polytomy" type="boolean" truevalue="--polytomy" falsevalue="" label="Collapse near-zero branches into polytomy" />
                <param argument="--treels" type="boolean" truevalue="--treels" falsevalue="" label="Write locally optimal trees into .treels file" />
                <param argument="--show-lh" type="boolean" truevalue="--show-lh" falsevalue="" label="Compute tree likelihood without optimisation" />
                <param argument="--terrace" type="boolean" truevalue="--terrace" falsevalue="" label="Check if the tree lies on a phylogenetic terrace" />
            </section>
            <section name="single_branch" expanded="False" title="Single branch tests">
                <param argument="--alrt" type="integer" optional="true" label="Specify number of replicates (&gt;=1000) to perform SH-like approximate likelihood ratio test (SH-aLRT) (Guindon et al., 2010)" help="If number of replicates is set to 0 (-alrt 0), then the parametric aLRT test (Anisimova and Gascuel 2006) is performed, instead of SH-aLRT."/>
                <param argument="--abayes" type="boolean" truevalue="-abayes" falsevalue="" checked="false" label="Perform approximate Bayes test (Anisimova et al., 2011)."/>
                <param argument="--lbp" type="integer" optional="true" label="Specify number of replicates (&gt;=1000) to perform fast local bootstrap probability method (Adachi and Hasegawa, 1996)."/>
            </section>
            <section name="tree_topology" expanded="False" title="Tree topology tests">
                <param argument="--trees" type="data" format="txt" optional="true" label="Specify a file containing a set of trees" help="IQ-TREE will compute the log-likelihoods of all trees."/>
                <param argument="--test" type="integer" optional="true" label="Specify the number of RELL (Kishino et al., 1990) replicates (&gt;=1000) to perform several tree topology tests for all trees passed via -z" help="The tests include bootstrap proportion (BP), KH test (Kishino and Hasegawa, 1989), SH test (Shimodaira and Hasegawa, 1999) and expected likelihood weights (ELW) (Strimmer and Rambaut, 2002)."/>
                <param argument="--test-weight" type="boolean" truevalue="--test-weight" falsevalue="" checked="false" label="Used together with --test to additionally perform the weighted-KH and weighted-SH tests."/>
                <param argument="--test-au" type="boolean" truevalue="--test-au" falsevalue="" checked="false" label="Used together with --test to additionally perform the approximately unbiased (AU) test (Shimodaira, 2002)" help="Note that you have to specify the number of replicates for the AU test via -test."/>
            </section>
            <section name="constructing_consensus" expanded="False" title="Constructing consensus tree">
                <param argument="--contree" type="boolean" truevalue="--contree" falsevalue="" checked="false" label="Compute consensus tree of the trees passed via -t" help="Resulting consensus tree is written to .contree file."/>
                <param argument="--connet" type="boolean" truevalue="--connet" falsevalue="" checked="false" label="Compute consensus network of the trees passed via -t" help="Resulting consensus network is written to .nex file."/>
                <param argument="--sup-min" type="float" value="0.0" optional="true" label="Specify a minimum threshold (between 0 and 1) to keep branches in the consensus tree"/>
                <param argument="--burnin" type="integer" optional="true" label="Specify a burn-in, which is the number of beginning trees passed via -t to discard before consensus construction" help="This is useful e.g. when summarizing trees from MrBayes analysis."/>
                <param argument="--support" type="data" format="nhx" optional="true" label="Specify an input "target" tree file" help="That means, support values are first extracted from the trees passed via -t, and then mapped onto the target tree. Resulting tree with assigned support values is written to .suptree file. This option is useful to map and compare support values from different approaches onto a single tree."/>
                <param argument="--suptag" type="text" optional="true" label="Specify name of a node in -sup target tree" help="The corresponding node of .suptree will then be assigned with IDs of trees where this node appears. Special option --suptag ALL will assign such IDs for all nodes of the target tree."/>
            </section>
            <section name="computing_robinson_foulds" expanded="False" title="Computing Robinson-Foulds distance">
                <param argument="--tree-dist-all" type="boolean" truevalue="--tree-dist-all" falsevalue="" checked="false" label="Compute all-to-all RF distances between all trees passed via -t"/>
                <param argument="--tree-dist" type="data" format="nhx" optional="true" label="Compute RF distances between -t trees and this set" />
                <param argument="--tree-dist2" type="data" format="nhx" optional="true" label="Like -rf but trees can have unequal taxon sets" />

            </section>
            <section name="generating_random" expanded="False" title="Generating random trees">
                <param argument="-r" type="integer" optional="true" label="Specify number of taxa" help="IQ-TREE will create a random tree under Yule-Harding model with specified number of taxa"/>
                <param argument="--rand" type="select" optional="true" label="Random tree creation">
                    <option value="--rand UNI">Uniform model</option>
                    <option value="--rand CAT">Random caterpillar tree</option>
                    <option value="--rand BAL">Random balanced tree</option>
                </param>
                <param name="branch_min" type="integer" optional="true" label="Minimum branch lengths of the random tree" />
                <param name="branch_mean" type="integer" optional="true" label="Median branch lengths of the random tree" />
                <param name="branch_max" type="integer" optional="true" label="Maximum branch lengths of the random tree" />
            </section>
            <section name="ancestral_state" title="Ancestral State Reconstruction">
                <param argument="--ancestral" type="boolean" truevalue="--ancestral" falsevalue="" label="Perform ancestral state reconstruction by empirical Bayes" />
                <param argument="--asr-min" type="float" optional="true" min="0" max="1" label="Minimum probability of ancestral state" />
            </section>
            <section name="symmetry_test" title="Symmetry Tests">
                <param argument="--symtest" type="boolean" truevalue="--symtest" falsevalue="" label="Perform three tests of symmetry" />
                <param argument="--symtest-remove-bad" type="boolean" truevalue="--symtest-remove-bad" falsevalue="" label="Do --symtest and remove bad partitions" />
                <param argument="--symtest-remove-good" type="boolean" truevalue="--symtest-remove-good" falsevalue="" label="Do --symtest and remove good partitions" />
                <param argument="--symtest-type" type="select" optional="true" label="Type of test to use">
                    <option value="MAR">Marginal</option>
                    <option value="INT">Internal</option>
                </param>
                <param argument="--symtest-pval" type="float" optional="true" label="P-value cutoff" />
                <param argument="--symtest-keep-zero" type="boolean" truevalue="--symtest-keep-zero" falsevalue="" label="Keep NAs in the tests" />
            </section>
            <section name="concordance_factor" title="Concordance Factor Analysis">
                <param argument="--gcf" type="data" format="nex" optional="true" label="Set of source trees for gene concordance factor" />
                <param argument="--df-tree" type="boolean" truevalue="--df-tree" falsevalue="" label="Write discordant trees associated with gDF1" />
                <param argument="--scf" type="integer" optional="true" label="Number of quartets for site concordance factor" />
                <param argument="--cf-verbose" type="boolean" truevalue="--cf-verbose" falsevalue="" label="Write CF per tree/locus" />
                <param argument="--cf-quartet" type="boolean" truevalue="--cf-quartet" falsevalue="" label="Write sCF for all resampled quartets to .cf.quartet" />
            </section>
        </section>
        <section name="bootstrap_parameters" title="Bootstrap Parameters">
            <section name="ultrafast_bootstrap" expanded="False" title="Ultrafast bootstrap parameters">
                <param argument="--ufboot" type="integer" optional="true" label="Specify number of bootstrap replicates (&gt;=1000)."/>
                <param argument="--ufjack" type="integer" optional="true" label="Specify number of replicates for ultrafast jackknife (&gt;=1000)."/>
                <param argument="--jack-prop" type="float" optional="true" min="0" max="1" label="Subsampling proportion for jackknife." help="Default: 0.5"/>
                <param argument="--boot-trees" type="boolean" truevalue="--boot-trees" falsevalue="" checked="false" label="Turn on writing bootstrap trees to .ufboot file"/>
                <param argument="--wbtl" type="boolean" truevalue="--wbtl" falsevalue="" checked="false" label="Like -boot-trees but bootstrap trees written with branch lengths"/>
                <param argument="--nmax" type="integer" value="1000" optional="true" label="Specify maximum number of iterations to stop"/>
                <param argument="--bcor" type="float" value="0.99" optional="true" label="Specify minimum correlation coefficient for UFBoot convergence criterion"/>
                <param argument="--nstep" type="integer" value="100" optional="true" label="Specify iteration interval checking for UFBoot convergence"/>
                <param argument="--beps" type="float" value="0.5" optional="true" label="Specify a small epsilon to break tie in RELL evaluation for bootstrap trees"/>
                <param argument="--sampling" type="text" optional="true" label="Specify the resampling strategies for partitioned analysis" help="By default, IQ-TREE resamples alignment sites within partitions. With --sampling GENE IQ-TREE will resample partitions. With --sampling GENESITE IQ-TREE will resample partitions and then resample sites within resampled partitions (Gadagkar et al., 2005).">
                    <sanitizer>
                        <valid initial="string.ascii_uppercase" />
                    </sanitizer>
                </param>
                <param argument="--bnni" type="boolean" truevalue="--bnni" falsevalue="" checked="false" label="Perform an additional step to further optimize UFBoot trees by nearest neighbor interchange (NNI) based directly on bootstrap alignments" help="This option is recommended in the presence of severe model violations. It increases computing time by 2-fold but reduces the risk of overestimating branch supports due to severe model violations. Introduced in IQ-TREE 1.6."/>
            </section>
            <section name="nonparametric_bootstrap" expanded="False" title="Nonparametric bootstrap">
                <param argument="--boot" type="integer" optional="true" label="Replicates for bootstrap + ML tree + consensus tree" help="This will perform both bootstrap and analysis on original alignment and provide a consensus tree."/>
                <param argument="--jack" type="integer" optional="true" label="Replicates for jackknife + ML tree + consensus tree" help="This will perform both bootstrap and analysis on original alignment and provide a consensus tree."/>
                <param argument="--jack-prop" type="float" optional="true" min="0" max="1" label="Subsampling proportion for jackknife." help="Default: 0.5"/>
                <param argument="--bcon" type="integer" optional="true" label="Replicates for bootstrap + consensus tree"/>
                <param argument="--bonly" type="integer" optional="true" label="Replicates for bootstrap only"/>
                <param argument="--tbe" type="boolean" truevalue="--tbe" falsevalue="" checked="false" label="Transfer bootstrap expectation"/>
            </section>
        </section>
        <section name="miscellaneous_options" expanded="False" title="Miscellaneous options">
            <param argument="-fconst" type="text" optional="true" label="Specify a list of comma-separated integer numbers" help="The number of entries should be equal to the number of states in the model (e.g. 4 for DNA and 20 for protein). IQ-TREE will then add a number of constant sites accordingly. For example, -fconst 10,20,15,40 will add 10 constant sites of all A, 20 constant sites of all C, 15 constant sites of all G and 40 constant sites of all T into the alignment.">
                <expand macro="sanitize_query"
                validinitial="string.digits,string.punctuation" />
            </param>
        </section>
    </inputs>
    <outputs>
        <data name="bionj" format="nhx" from_work_dir="*.bionj" label="${tool.name} on ${on_string}: BIONJ Tree" />
        <data name="treefile" format="nhx" from_work_dir="*.treefile" label="${tool.name} on ${on_string}: MaxLikelihood Tree" />
        <data name="consensus_tree" format="nhx" from_work_dir="*.contree" label="${tool.name} on ${on_string}: Consensus Tree">
            <filter>tree_parameters['constructing_consensus']['contree']</filter>
        </data>
        <data name="mldist" format="mldist" from_work_dir="*.mldist" label="${tool.name} on ${on_string}: MaxLikelihood Distance Matrix"/>
        <data name="splits" format="nex" from_work_dir="*.splits.nex" label="${tool.name} on ${on_string}: Occurence Frequencies in Bootstrap Trees" />
        <data name="iqtree" format="iqtree" from_work_dir="*.iqtree" label="${tool.name} on ${on_string}: Report and Final Tree" />
        <data name="mlrate" format="data" from_work_dir="*.mlrate" label="${tool.name} on ${on_string}: ML Rates">
            <filter>modelling_parameters['rate_heterogeneity']['mlrate']</filter>
        </data>
        <data name="timetree" format="nex" from_work_dir="PREF.timetree.nex" label="${tool.name} on ${on_string}: Tree labeled with dates">
            <filter>time_tree['date_source']['select_source'] != 'none'</filter>
        </data>
        <data name="lsd_report" format="txt" from_work_dir="PREF.timetree.lsd" label="${tool.name} on ${on_string}: LSD Report">
            <filter>time_tree['date_source']['select_source'] != 'none'</filter>
        </data>
    </outputs>
    <tests>
        <test expect_num_outputs="5">
            <param name="seed" value="1257" />
            <param name="seqtype" value="AA" />
            <param name="s" value="example.phy" />
            <param name="m" value="TEST" />
            <param name="msub" value="nuclear" />
            <param name="madd" value="LG4M,LG4X" />
            <param name="merit" value="AICc" />
            <param name="ufboot" value="1000" />
            <output name="bionj">
                <assert_contents>
                    <has_text_matching expression=".*Whale.*" />
                    <has_text_matching expression=".*Human.*" />
                </assert_contents>
            </output>
            <output name="iqtree">
                <assert_contents>
                    <has_text_matching expression="GTR\+F(\s+((-|\d|\.)+))+" />
                </assert_contents>
            </output>
            <output name="mldist">
                <assert_contents>
                    <has_line_matching expression="^Frog(\s+((\d|\.)+))+\s+$" />
                    <has_line_matching expression="^Whale(\s+((\d|\.)+))+\s+$" />
                    <has_line_matching expression="^Cow(\s+((\d|\.)+))+\s+$" />
                </assert_contents>
            </output>
            <output name="treefile">
                <assert_contents>
                    <has_line_matching expression="\(LngfishAu:(\d|\..)+,\(LngfishSA:(\d.)+,.*" />
                </assert_contents>
            </output>
            <output name="consensus_tree">
                <assert_contents>
                    <has_line_matching
                        expression="\(LngfishAu:(\d|\..)+,\(LngfishSA:(\d.)+,.*\)\d+:(\d|\.)+,.*" />
                </assert_contents>
            </output>
            <output name="splits">
                <assert_contents>
                    <has_line line="BEGIN Splits;" />
                    <has_line line="END; [Splits]" />
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs="5">
            <!-- bootstrap sans model -->
            <param name="seed" value="1257" />
            <param name="seqtype" value="AA" />
            <param name="s" value="example.phy" />
            <!-- <param name="m" value="TESTONLY" /> -->
            <param name="msub" value="nuclear" />
            <param name="cmin" value="2" />
            <param name="cmax" value="10" />
            <param name="merit" value="AICc" />
            <param name="madd" value="LG4M,LG4X" />
            <param name="ninit" value="100" />
            <param name="ntop" value="20" />
            <param name="nbest" value="5" />
            <param name="nstop" value="100" />
            <param name="radius" value="6" />
            <param name="perturb" value="0.5" />
            <param name="sup_min" value="0.0" />
            <param name="nmax" value="1000" />
            <param name="bcor" value="0.99" />
            <param name="nstep" value="100" />
            <param name="beps" value="0.5" />
            <param name="b" value="2" />
            <output name="iqtree">
                <assert_contents>
                    <has_text_matching expression="GTR\+F\+I(\s+((-|\d|\.)+))+" />
                </assert_contents>
            </output>
            <output name="treefile">
                <assert_contents>
                    <has_line_matching expression="\(LngfishAu:(\d|\..)+,\(LngfishSA:(\d.)+,.*" />
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs="5">
            <!-- model sans bootstrap -->
            <param name="seed" value="1257" />
            <param name="seqtype" value="AA" />
            <param name="s" value="example.phy" />
            <param name="m" value="TESTONLY" />
            <param name="msub" value="nuclear" />
            <param name="cmin" value="2" />
            <param name="cmax" value="10" />
            <param name="merit" value="AICc" />
            <param name="madd" value="LG4M,LG4X" />
            <param name="ninit" value="100" />
            <param name="ntop" value="20" />
            <param name="nbest" value="5" />
            <param name="nstop" value="100" />
            <param name="radius" value="6" />
            <param name="perturb" value="0.5" />
            <param name="sup_min" value="0.0" />
            <param name="nmax" value="1000" />
            <param name="bcor" value="0.99" />
            <param name="nstep" value="100" />
            <param name="beps" value="0.5" />
            <!-- <param name="b" value="100" /> -->
            <output name="iqtree">
                <assert_contents>
                    <has_text_matching expression="GTR\+F\+I\+G4(\s+((-|\d|\.)+))+" />
                </assert_contents>
            </output>
            <output name="treefile">
                <assert_contents>
                    <has_line_matching expression="\(LngfishAu:(\d|\..)+,\(LngfishSA:(\d.)+,.*" />
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs="5">
            <param name="s" value="example.phy" />
            <output name="iqtree">
                <assert_contents>
                    <has_text_matching expression=".*Human.*Whale.*" />
                </assert_contents>
            </output>
            <output name="treefile">
                <assert_contents>
                    <has_text_matching expression="\(LngfishAu:(\d|\..)+,\(LngfishSA:(\d.)+,.*" />
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs="5">
            <param name="s" value="example.phy" />
            <param name="opt_custommodel" value="true" />
            <param name="m" value="GTR+G{0.9}" />
            <output name="iqtree">
                <assert_contents>
                    <has_text_matching expression=".*Human.*Whale.*" />
                </assert_contents>
            </output>
            <output name="treefile">
                <assert_contents>
                    <has_text_matching expression="\(LngfishAu:(\d|\..)+,\(LngfishSA:(\d.)+,.*" />
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs="5">
            <param name="s" value="short.fasta" />
            <param name="short_alignments" value="true" />
            <output name="treefile">
                <assert_contents>
                    <has_line_matching expression="\(NC_045512.+\(MT019531.+MT019532.+" />
                </assert_contents>
            </output>
        </test>
        <test expect_num_outputs="7">
            <param name="s" value="dates.fa" />
            <param name="n" value="100" />
            <param name="seed" value="122125" />
            <param name="select_source" value="dataset" />
            <param name="date" value="dates.tabular" />
            <output name="timetree">
                <assert_contents>
                    <has_line_matching expression=".+222-3pu_03-28-01_985737600.+" />
                </assert_contents>
            </output>
            <output name="lsd_report">
                <assert_contents>
                    <has_line_matching expression="^LEAST-SQUARE METHODS.+" />
                </assert_contents>
            </output>
        </test>
    </tests>
    <help><![CDATA[
IQ-TREE
=======

The full documentation can be found here_.

.. _here : http://www.iqtree.org/doc/

General Tutorial
===================

Input data
----------

IQ-TREE takes as input a *multiple sequence alignment* and will reconstruct an evolutionary tree that is best explained by the input data. The input alignment can be in various common formats. For example the PHYLIP_ format which may look like:

.. _PHYLIP: http://evolution.genetics.washington.edu/phylip/doc/sequence.html

::

    7 28
    Frog       AAATTTGGTCCTGTGATTCAGCAGTGAT
    Turtle     CTTCCACACCCCAGGACTCAGCAGTGAT
    Bird       CTACCACACCCCAGGACTCAGCAGTAAT
    Human      CTACCACACCCCAGGAAACAGCAGTGAT
    Cow        CTACCACACCCCAGGAAACAGCAGTGAC
    Whale      CTACCACGCCCCAGGACACAGCAGTGAT
    Mouse      CTACCACACCCCAGGACTCAGCAGTGAT

This tiny alignment contains 7 DNA sequences from several animals with the sequence length of 28 nucleotides. IQ-TREE also supports other file formats such as FASTA, NEXUS, CLUSTALW. The FASTA file for the above example may look like this:

::

    >Frog
    AAATTTGGTCCTGTGATTCAGCAGTGAT
    >Turtle
    CTTCCACACCCCAGGACTCAGCAGTGAT
    >Bird
    CTACCACACCCCAGGACTCAGCAGTAAT
    >Human
    CTACCACACCCCAGGAAACAGCAGTGAT
    >Cow
    CTACCACACCCCAGGAAACAGCAGTGAC
    >Whale
    CTACCACGCCCCAGGACACAGCAGTGAT
    >Mouse
    CTACCACACCCCAGGACTCAGCAGTGAT

**NOTE**: If you have raw sequences, you need to first apply alignment programs like MAFFT_ or ClustalW_ to align the sequences, before feeding them into IQ-TREE.

.. _MAFFT: http://mafft.cbrc.jp/alignment/software/
.. _ClustalW: http://www.clustal.org


Running example
---------------------

From the download_ there is an example alignment called `example.phy`
in PHYLIP format. This example contains parts of the mitochondrial DNA sequences of several animals (Source: `Phylogenetic Handbook`_)

.. _`Phylogenetic Handbook` : http://www.kuleuven.be/aidslab/phylogenybook/home.html)).
.. _download: http://www.iqtree.org/#download

You can now start to reconstruct a maximum-likelihood tree
from this alignment by entering (assuming that you are now in the same folder with `example.phy`):

::iqtree -s example.phy -st AA -seed 9999 -m TESTNEW -msub nuclear -madd LG4M,LG4x -merit AICc --ufboot 2000

* **-s** is the option to specify the name of the alignment file

* **-st** specifies the sequence type as amino-acid

* **-seed** ensures that the output files remain the same for subsequent runs

* **-m** sets the modelling parameter for standard model selection

* **-msub** determines the type sub-modelling

* **-madd** provides an additional selection mixed models

* **-merit** asserts the type of optimality criterion

* **-ufboot** defines the number of replicates


Each of these parameters are available under the relevant sub-sections in the main tool interface.

At the end of the run IQ-TREE will write several output files including:

* **example.phy.iqtree**: the main report file that is self-readable. You should look at this file to see the computational results. It also contains a textual representation of the final tree (see below).

* **example.phy.treefile**: the ML tree in NEWICK format, which can be visualized by any supported tree viewer programs like FigTree or  iTOL.

**NOTE**: Starting with version 1.5.4, with this simple command IQ-TREE will by default perform ModelFinder to find the best-fit substitution model and then infer a phylogenetic tree using the selected model.

For this example data the resulting maximum-likelihood tree may look like this (extracted from **.iqtree** file):

**NOTE**: Tree is UNROOTED although outgroup taxon 'LngfishAu' is drawn at root

::

    +--------------LngfishAu
    |
    |        +--------------LngfishSA
    +--------|
    |        +--------------LngfishAf
    |
    |      +-------------------Frog
    +------|
    |               +-----------------Turtle
    |         +-----|
    |         |     |      +-----------------------Sphenodon
    |         |     |   +--|
    |         |     |   |  +--------------------------Lizard
    |         |     +---|
    |         |         |      +---------------------Crocodile
    |         |         +------|
    |         |                +------------------Bird
    +---------|
    |                  +----------------Human
    |               +--|
    |               |  |  +--------Seal
    |               |  +--|
    |               |     |   +-------Cow
    |               |     +---|
    |               |         +---------Whale
    |          +----|
    |          |    |         +------Mouse
    |          |    +---------|
    |          |              +--------Rat
    +----------|
    |   +----------------Platypus
    +---|
    +-------------Opossum


This makes sense as the mammals (**Human** to **Opossum**) form a clade, whereas the reptiles **Turtle** to **Crocodile**) and **Bird** form a separate sister clade. Here the tree is drawn at the *outgroup* Lungfish which is more accient than other species in this example. However, please note that IQ-TREE always produces an **unrooted tree** as it knows nothing about this biological background; IQ-TREE simply draws the tree this way as **LngfishAu** is the first sequence occuring in the alignment.

Choosing the right substitution model
-------------------------------------

IQ-TREE will choose the best model for you automatically if specify any of the TEST models, but valid custom models can also be specified that conform to those found in Models_ page.

.. _Models: http://www.iqtree.org/doc/Substitution-Models#binary-and-morphological-models


------------------------------

Advanced Parameter Selection
============================

Using codon models
------------------

IQ-TREE supports a number of codon models. You need to input a protein-coding DNA alignment and specify codon data by option **-st CODON** (Otherwise, IQ-TREE applies DNA model because it detects that your alignment has DNA sequences):

::

  iqtree -s coding_gene.phy -st CODON

If your alignment length is not divisible by 3, IQ-TREE will stop with an error message. IQ-TREE will group sites 1,2,3 into codon site 1; sites 4,5,6 to codon site 2; etc. Moreover, any codon, which has at least one gap/unknown/ambiguous nucleotide, will be treated as unknown codon character.

Note that the above command assumes the standard genetic code. If your sequences follow 'The Invertebrate Mitochondrial Code', then run:

::

   iqtree -s coding_gene.phy -st CODON5

Note that ModelFinder works for codon alignments. IQ-TREE version >= 1.5.4 will automatically invokes ModelFinder to find the best-fit codon model.


Assessing branch supports with ultrafast bootstrap approximation
----------------------------------------------------------------

To overcome the computational burden required by the nonparametric bootstrap, IQ-TREE introduces an ultrafast bootstrap approximation (UFBoot) ([Minh et al., 2013]) that is  orders of magnitude faster than the standard procedure and provides relatively unbiased branch support values. Citation for UFBoot:

   B.Q. Minh, M.A.T. Nguyen, and A. von Haeseler (2013) Ultrafast approximation for phylogenetic bootstrap. _Mol. Biol. Evol., 30:1188-1195.

::

   iqtree -s example.phy -m TIM2+I+G --ufboot 1000

**-ufboot** specifies the number of bootstrap replicates where 1000 is the minimum number recommended. The section  **MAXIMUM LIKELIHOOD TREE** in  **example.phy.iqtree** shows a textual representation of the maximum likelihood tree with branch support values in percentage. The NEWICK format of the tree is printed to the file  **example.phy.treefile**. In addition, IQ-TREE writes the following files:

* **example.phy.contree**: the consensus tree with assigned branch supports where branch lengths are optimized  on the original alignment.

* **example.phy.splits**: support values in percentage for all splits (bipartitions), computed as the occurence frequencies in the bootstrap trees. This file is in "star-dot" format.

* **example.phy.splits.nex**: has the same information as **example.phy.splits** but in NEXUS format, which can be viewed with the program SplitsTree_ to explore the conflicting signals in the data. So it is more informative than consensus tree, e.g. you can see how highly supported the second best conflicting split is, which had no chance to enter the consensus tree.

.. _SplitsTree: http://www.splitstree.org


Reducing impact of severe model violations with UFBoot
------------------------------------------------------

Starting with IQ-TREE version 1.6 we provide a new option **-bnni** to reduce the risk of overestimating branch supports with UFBoot due to severe model violations. With this option UFBoot will further optimize each bootstrap tree using a hill-climbing nearest neighbor interchange (NNI) search based directly on the corresponding bootstrap alignment.

Thus, if severe model violations are present in the data set at hand, users are advised to append **-bnni** to the regular UFBoot command:

iqtree -s example.phy -m TIM2+I+G --ufboot 1000 -bnni

For more details see:

  D.T. Hoang, O. Chernomor, A. von Haeseler, B.Q. Minh, L.S. Vinh (2017) UFBoot2: Improving the ultrafast bootstrap approximation.


Assessing branch supports with  standard nonparametric bootstrap
----------------------------------------------------------------

The standard nonparametric bootstrap is invoked by  the  **-b** option:

iqtree -s example.phy -m TIM2+I+G -b 100

**-b** specifies the number of bootstrap replicates where 100
is the minimum recommended number. The output files are similar to those produced by the UFBoot procedure.



Assessing branch supports with single branch tests
--------------------------------------------------

IQ-TREE provides an implementation of the SH-like approximate likelihood ratio test ([Guindon et al., 2010]). To perform this test,  run:

::

  iqtree -s example.phy -m TIM2+I+G --alrt 1000

**--alrt** specifies the number of bootstrap replicates for SH-aLRT where 1000 is the minimum number recommended.

IQ-TREE also supports other tests such as the aBayes test (Anisimova et al., 2011) and the local bootstrap test (Adachi and Hasegawa, 1996).

You can also perform both SH-aLRT and the ultrafast bootstrap within one single run:

::

  iqtree -s example.phy -m TIM2+I+G --alrt 1000 --ufboot 1000

The branches of the resulting **.treefile** will be assigned with both SH-aLRT and UFBoot support values, which are readable by any tree viewer program like FigTree, Dendroscope or ETE. You can also look at the textual tree figure in **.iqtree** file:

**NOTE**: Tree is UNROOTED although outgroup taxon 'LngfishAu' is drawn at root
Numbers in parentheses are SH-aLRT support (%) / ultrafast bootstrap support (%)

::

    +-------------LngfishAu
    |
    |       +--------------LngfishSA
    +-------| (100/100)
    |       +------------LngfishAf
    |
    |      +--------------------Frog
    +------| (99.8/100)
    |                     +-----------------Turtle
    |                  +--| (85/72)
    |                  |  |    +------------------------Crocodile
    |                  |  +----| (96.5/97)
    |                  |       +------------------Bird
    |               +--| (39/51)
    |               |  +---------------------------Sphenodon
    |         +-----| (98.2/99)
    |         |     +-------------------------------Lizard
    +---------| (100/100)
    |                   +--------------Human
    |                +--| (92.3/93)
    |                |  |  +------Seal
    |                |  +--| (68.3/75)
    |                |     |  +-----Cow
    |                |     +--| (99.7/100)
    |                |        +-------Whale
    |           +----| (99.1/100)
    |           |    |         +---Mouse
    |           |    +---------| (100/100)
    |           |              +------Rat
    +-----------| (100/100)
    |  +--------------Platypus
    +--| (93/98)
    +-----------Opossum


From this figure, the branching patterns within reptiles are poorly supported (e.g. **Sphenodon** with SH-aLRT: 39%, UFBoot: 51% and **Turtle** with SH-aLRT: 85%, UFBoot: 72%) as well as the phylogenetic position of **Seal** within mammals (SH-aLRT: 68.3%, UFBoot: 75%). Other branches appear to be well supported.
    ]]></help>
    <citations>
        <citation type="doi">10.1038/nmeth.4285</citation>
        <citation type="doi">10.1093/molbev/msu300</citation>
        <citation type="doi">10.1093/molbev/msx281</citation>
        <citation type="doi">10.1093/sysbio/syx068</citation>
        <citation type="doi">10.1093/sysbio/syw037</citation>
        <citation type="doi">10.1016/j.jtbi.2016.07.042</citation>
        <citation type="doi">10.1093/molbev/mst024</citation>
    </citations>
</tool>
