<?xml version="1.0" standalone="yes"?>
<!-- $Id: testML.xml,v 1.2 2005/07/11 23:22:40 rambaut Exp $ -->
<!-- Tests the ML engine -->

<beast>

    <!-- The list of taxa analyse (can also include dates/ages).                 -->
    <!-- ntax=6                                                                  -->
    <taxa id="taxa">
        <taxon id="human"/>
        <taxon id="chimp"/>
        <taxon id="mouse"/>
    </taxa>

    <alignment id="alignment1" dataType="nucleotide">
        <sequence>
            <taxon idref="human"/>
            AAAACCCCGGGG
        </sequence>
        <sequence>
            <taxon idref="chimp"/>
            AAAGGCCCGGTG
        </sequence>
        <sequence>
            <taxon idref="mouse"/>
            ATAGTGCCTTTG
        </sequence>
    </alignment>

    <patterns id="patterns1" from="1">
        <alignment idref="alignment1"/>
    </patterns>

    <constantSize id="initialDemo" units="substitutions">
        <populationSize>
            <parameter id="initialDemo.popSize" value="0.0001"/>
        </populationSize>
    </constantSize>

    <!-- Generate a random starting tree under the coalescent process            -->
    <coalescentTree id="startingTree">
        <taxa idref="taxa"/>
        <constantSize idref="initialDemo"/>
    </coalescentTree>

    <newick id="shortTree"> <!-- rescaleHeight="0.1">   -->
        ((human:1.0,chimp:1.0):1.0,mouse:2.0);
    </newick>

    <treeModel id="treeModel">
        <!-- <coalescentTree idref="startingTree"/>    -->
        <tree idref="shortTree"/>
        <rootHeight>
            <parameter id="treeModel.rootHeight"/>
        </rootHeight>
        <nodeHeights internalNodes="true">
            <parameter id="treeModel.internalNodeHeights"/>
        </nodeHeights>
        <nodeHeights internalNodes="true" rootNode="true">
            <parameter id="treeModel.allInternalNodeHeights"/>
        </nodeHeights>
    </treeModel>

    <!-- The HKY substitution model (Hasegawa, Kishino & Yano, 1985)             -->
    <hkyModel id="hky">
        <frequencies>
            <frequencyModel dataType="nucleotide">
                <!--<alignment idref="alignment"/>-->
                <frequencies>
                    <parameter id="hky.frequencies" value="0.1 0.3 0.2 0.4"/>
                </frequencies>
            </frequencyModel>
        </frequencies>
        <kappa>
            <parameter id="hky.kappa" value="1.0" lower="0.0" upper="5.0"/>
        </kappa>
    </hkyModel>
    <!-- site model                                                              -->
    <siteModel id="siteModel">
        <substitutionModel>
            <hkyModel idref="hky"/>
        </substitutionModel>
        <mutationRate>
            <parameter id="siteModel.mu" value="1.0" lower="0.0"/>
        </mutationRate>
    </siteModel>


    <nodePosteriorLikelihood id="treeLikelihood1">
        <patterns idref="patterns1"/>
        <treeModel idref="treeModel"/>
        <siteModel idref="siteModel"/>
        <hkyModel idref="hky"/>
    </nodePosteriorLikelihood>

    <yuleModel id="yule" units="substitutions">
        <birthRate>
            <parameter id="yule.birthRate" value="1.0" lower="0.0"
                       upper="1000000.0"/>
        </birthRate>
    </yuleModel>

    <speciationLikelihood id="speciation">
        <model>
            <yuleModel idref="yule"/>
        </model>
        <speciesTree>
            <treeModel idref="treeModel"/>
        </speciesTree>
    </speciationLikelihood>


    <operators id="operators">
        <scaleOperator scaleFactor="0.5" weight="1">
            <parameter idref="hky.kappa"/>
        </scaleOperator>
        <!-- <scaleOperator scaleFactor="0.5" weight="1">
              <parameter idref="treeModel.rootHeight"/>
        </scaleOperator>    -->
        <scaleOperator scaleFactor="0.75" weight="1">
            <parameter idref="yule.birthRate"/>
        </scaleOperator>
        <uniformOperator weight="10">
            <parameter idref="treeModel.internalNodeHeights"/>
        </uniformOperator>
        <subtreeSlide weight="5" gaussian="true" size="1.0">
            <treeModel idref="treeModel"/>
        </subtreeSlide>
        <narrowExchange weight="1">
            <treeModel idref="treeModel"/>
        </narrowExchange>
        <wideExchange weight="1">
            <treeModel idref="treeModel"/>
        </wideExchange>
        <wilsonBalding weight="1">
            <treeModel idref="treeModel"/>
        </wilsonBalding>
    </operators>

    <mcmc id="mcmc" chainLength="3000000">
        <posterior id="posterior">
            <likelihood id="likelihood">
                <treeLikelihood idref="treeLikelihood1"/>
            </likelihood>
            <prior id="priors">
                <speciationLikelihood idref="speciation"/>
                <jeffreysPrior>
                    <parameter idref="yule.birthRate"/>
                </jeffreysPrior>
                <jeffreysPrior>
                    <parameter idref="hky.kappa"/>
                </jeffreysPrior>
            </prior>
        </posterior>
        <operators idref="operators"/>
        <log logEvery="100000">
            <column label="Posterior" dp="4" width="12">
                <likelihood idref="posterior"/>
            </column>
            <column label="Likelihood" dp="4" width="12">
                <likelihood idref="likelihood"/>
            </column>
            <column label="Prior" dp="4" width="12">
                <prior idref="priors"/>
            </column>
            <column label="Root Height" sf="6" width="12">
                <parameter idref="treeModel.rootHeight"/>
            </column>
            <column label="Kappa" sf="6" width="12">
                <parameter idref="hky.kappa"/>
            </column>
            <column label="MutationRate" sf="6" width="12">
                <parameter idref="siteModel.mu"/>
            </column>
        </log>
        <logTree logEvery="100000" nexusFormat="true" fileName="ancestor.trees">
            <treeModel idref="treeModel"/>
            <!-- <nodePosteriorLikelihood idref="treeLikelihood1"/>     -->
            <avgPosteriorIBDReporter id="posteriorIBD">
                <nodePosteriorLikelihood idref="treeLikelihood1"/>
                <treeModel idref="treeModel"/>
                <parameter idref="siteModel.mu"/>
                <hkyModel idref="hky"/>
            </avgPosteriorIBDReporter>
        </logTree>
    </mcmc>

    <report>
        <property name="timer">
            <object idref="mcmc"/>
        </property>
    </report>

</beast>