<beast version='2.0'
       namespace='beast.evolution:beast.evolution.alignment:beast.core:beast.evolution.tree.coalescent:beast.core.util:beast.evolution.nuc:beast.evolution.operators:beast.evolution.sitemodel:beast.evolution.substitutionmodel:beast.evolution.likelihood'>


    <!-- The sequence alignment                                                  -->
    <!-- ntax=6 nchar=768                                                        -->
    <!-- npatterns=69                                                            -->
    <data id="alignment" dataType="nucleotide">
        <sequence taxon="human">
            AGAAATATGTCTGATAAAAGAGTTACTTTGATAGAGTAAATAATAGGAGCTTAAACCCCCTTATTTCTACTAGGACTATGAGAATCGAACCCATCCCTGAGAATCCAAAATTCTCCGTGCCACCTATCACACCCCATCCTAAGTAAGGTCAGCTAAATAAGCTATCGGGCCCATACCCCGAAAATGTTGGTTATACCCTTCCCGTACTAAGAAATTTAGGTTAAATACAGACCAAGAGCCTTCAAAGCCCTCAGTAAGTTG-CAATACTTAATTTCTGTAAGGACTGCAAAACCCCACTCTGCATCAACTGAACGCAAATCAGCCACTTTAATTAAGCTAAGCCCTTCTAGACCAATGGGACTTAAACCCACAAACACTTAGTTAACAGCTAAGCACCCTAATCAAC-TGGCTTCAATCTAAAGCCCCGGCAGG-TTTGAAGCTGCTTCTTCGAATTTGCAATTCAATATGAAAA-TCACCTCGGAGCTTGGTAAAAAGAGGCCTAACCCCTGTCTTTAGATTTACAGTCCAATGCTTCA-CTCAGCCATTTTACCACAAAAAAGGAAGGAATCGAACCCCCCAAAGCTGGTTTCAAGCCAACCCCATGGCCTCCATGACTTTTTCAAAAGGTATTAGAAAAACCATTTCATAACTTTGTCAAAGTTAAATTATAGGCT-AAATCCTATATATCTTA-CACTGTAAAGCTAACTTAGCATTAACCTTTTAAGTTAAAGATTAAGAGAACCAACACCTCTTTACAGTGA
        </sequence>
        <sequence taxon="chimp">
            AGAAATATGTCTGATAAAAGAATTACTTTGATAGAGTAAATAATAGGAGTTCAAATCCCCTTATTTCTACTAGGACTATAAGAATCGAACTCATCCCTGAGAATCCAAAATTCTCCGTGCCACCTATCACACCCCATCCTAAGTAAGGTCAGCTAAATAAGCTATCGGGCCCATACCCCGAAAATGTTGGTTACACCCTTCCCGTACTAAGAAATTTAGGTTAAGCACAGACCAAGAGCCTTCAAAGCCCTCAGCAAGTTA-CAATACTTAATTTCTGTAAGGACTGCAAAACCCCACTCTGCATCAACTGAACGCAAATCAGCCACTTTAATTAAGCTAAGCCCTTCTAGATTAATGGGACTTAAACCCACAAACATTTAGTTAACAGCTAAACACCCTAATCAAC-TGGCTTCAATCTAAAGCCCCGGCAGG-TTTGAAGCTGCTTCTTCGAATTTGCAATTCAATATGAAAA-TCACCTCAGAGCTTGGTAAAAAGAGGCTTAACCCCTGTCTTTAGATTTACAGTCCAATGCTTCA-CTCAGCCATTTTACCACAAAAAAGGAAGGAATCGAACCCCCTAAAGCTGGTTTCAAGCCAACCCCATGACCTCCATGACTTTTTCAAAAGATATTAGAAAAACTATTTCATAACTTTGTCAAAGTTAAATTACAGGTT-AACCCCCGTATATCTTA-CACTGTAAAGCTAACCTAGCATTAACCTTTTAAGTTAAAGATTAAGAGGACCGACACCTCTTTACAGTGA
        </sequence>
        <sequence taxon="bonobo">
            AGAAATATGTCTGATAAAAGAATTACTTTGATAGAGTAAATAATAGGAGTTTAAATCCCCTTATTTCTACTAGGACTATGAGAGTCGAACCCATCCCTGAGAATCCAAAATTCTCCGTGCCACCTATCACACCCCATCCTAAGTAAGGTCAGCTAAATAAGCTATCGGGCCCATACCCCGAAAATGTTGGTTATACCCTTCCCGTACTAAGAAATTTAGGTTAAACACAGACCAAGAGCCTTCAAAGCTCTCAGTAAGTTA-CAATACTTAATTTCTGTAAGGACTGCAAAACCCCACTCTGCATCAACTGAACGCAAATCAGCCACTTTAATTAAGCTAAGCCCTTCTAGATTAATGGGACTTAAACCCACAAACATTTAGTTAACAGCTAAACACCCTAATCAGC-TGGCTTCAATCTAAAGCCCCGGCAGG-TTTGAAGCTGCTTCTTTGAATTTGCAATTCAATATGAAAA-TCACCTCAGAGCTTGGTAAAAAGAGGCTTAACCCCTGTCTTTAGATTTACAGTCCAATGCTTCA-CTCAGCCATTTTACCACAAAAAAGGAAGGAATCGAACCCCCTAAAGCTGGTTTCAAGCCAACCCCATGACCCCCATGACTTTTTCAAAAGATATTAGAAAAACTATTTCATAACTTTGTCAAAGTTAAATTACAGGTT-AAACCCCGTATATCTTA-CACTGTAAAGCTAACCTAGCATTAACCTTTTAAGTTAAAGATTAAGAGGACCAACACCTCTTTACAGTGA
        </sequence>
        <sequence taxon="gorilla">
            AGAAATATGTCTGATAAAAGAGTTACTTTGATAGAGTAAATAATAGAGGTTTAAACCCCCTTATTTCTACTAGGACTATGAGAATTGAACCCATCCCTGAGAATCCAAAATTCTCCGTGCCACCTGTCACACCCCATCCTAAGTAAGGTCAGCTAAATAAGCTATCGGGCCCATACCCCGAAAATGTTGGTCACATCCTTCCCGTACTAAGAAATTTAGGTTAAACATAGACCAAGAGCCTTCAAAGCCCTTAGTAAGTTA-CAACACTTAATTTCTGTAAGGACTGCAAAACCCTACTCTGCATCAACTGAACGCAAATCAGCCACTTTAATTAAGCTAAGCCCTTCTAGATCAATGGGACTCAAACCCACAAACATTTAGTTAACAGCTAAACACCCTAGTCAAC-TGGCTTCAATCTAAAGCCCCGGCAGG-TTTGAAGCTGCTTCTTCGAATTTGCAATTCAATATGAAAT-TCACCTCGGAGCTTGGTAAAAAGAGGCCCAGCCTCTGTCTTTAGATTTACAGTCCAATGCCTTA-CTCAGCCATTTTACCACAAAAAAGGAAGGAATCGAACCCCCCAAAGCTGGTTTCAAGCCAACCCCATGACCTTCATGACTTTTTCAAAAGATATTAGAAAAACTATTTCATAACTTTGTCAAGGTTAAATTACGGGTT-AAACCCCGTATATCTTA-CACTGTAAAGCTAACCTAGCGTTAACCTTTTAAGTTAAAGATTAAGAGTATCGGCACCTCTTTGCAGTGA
        </sequence>
        <sequence taxon="orangutan">
            AGAAATATGTCTGACAAAAGAGTTACTTTGATAGAGTAAAAAATAGAGGTCTAAATCCCCTTATTTCTACTAGGACTATGGGAATTGAACCCACCCCTGAGAATCCAAAATTCTCCGTGCCACCCATCACACCCCATCCTAAGTAAGGTCAGCTAAATAAGCTATCGGGCCCATACCCCGAAAATGTTGGTTACACCCTTCCCGTACTAAGAAATTTAGGTTA--CACAGACCAAGAGCCTTCAAAGCCCTCAGCAAGTCA-CAGCACTTAATTTCTGTAAGGACTGCAAAACCCCACTTTGCATCAACTGAGCGCAAATCAGCCACTTTAATTAAGCTAAGCCCTCCTAGACCGATGGGACTTAAACCCACAAACATTTAGTTAACAGCTAAACACCCTAGTCAAT-TGGCTTCAGTCCAAAGCCCCGGCAGGCCTTAAAGCTGCTCCTTCGAATTTGCAATTCAACATGACAA-TCACCTCAGGGCTTGGTAAAAAGAGGTCTGACCCCTGTTCTTAGATTTACAGCCTAATGCCTTAACTCGGCCATTTTACCGCAAAAAAGGAAGGAATCGAACCTCCTAAAGCTGGTTTCAAGCCAACCCCATAACCCCCATGACTTTTTCAAAAGGTACTAGAAAAACCATTTCGTAACTTTGTCAAAGTTAAATTACAGGTC-AGACCCTGTGTATCTTA-CATTGCAAAGCTAACCTAGCATTAACCTTTTAAGTTAAAGACTAAGAGAACCAGCCTCTCTTTGCAATGA
        </sequence>
        <sequence taxon="siamang">
            AGAAATACGTCTGACGAAAGAGTTACTTTGATAGAGTAAATAACAGGGGTTTAAATCCCCTTATTTCTACTAGAACCATAGGAGTCGAACCCATCCTTGAGAATCCAAAACTCTCCGTGCCACCCGTCGCACCCTGTTCTAAGTAAGGTCAGCTAAATAAGCTATCGGGCCCATACCCCGAAAATGTTGGTTATACCCTTCCCATACTAAGAAATTTAGGTTAAACACAGACCAAGAGCCTTCAAAGCCCTCAGTAAGTTAACAAAACTTAATTTCTGCAAGGGCTGCAAAACCCTACTTTGCATCAACCGAACGCAAATCAGCCACTTTAATTAAGCTAAGCCCTTCTAGATCGATGGGACTTAAACCCATAAAAATTTAGTTAACAGCTAAACACCCTAAACAACCTGGCTTCAATCTAAAGCCCCGGCAGA-GTTGAAGCTGCTTCTTTGAACTTGCAATTCAACGTGAAAAATCACTTCGGAGCTTGGCAAAAAGAGGTTTCACCTCTGTCCTTAGATTTACAGTCTAATGCTTTA-CTCAGCCACTTTACCACAAAAAAGGAAGGAATCGAACCCTCTAAAACCGGTTTCAAGCCAGCCCCATAACCTTTATGACTTTTTCAAAAGATATTAGAAAAACTATTTCATAACTTTGTCAAAGTTAAATCACAGGTCCAAACCCCGTATATCTTATCACTGTAGAGCTAGACCAGCATTAACCTTTTAAGTTAAAGACTAAGAGAACTACCGCCTCTTTACAGTGA
        </sequence>
    </data>



    <run spec="MCMC" id="mcmc" chainLength="10000000"> <!--autoOptimize="true"-->
        <init spec='beast.evolution.tree.RandomTree' id='randomTree' initial='@tree' taxa='@alignment'>
            <populationModel spec='ConstantPopulation' popSize='@popSize'/>
            <constraint idref='mrcaPrior2'/>
            <constraint idref='mrcaPrior1'/>
        </init>

        <state>
            <stateNode spec='parameter.RealParameter' id="hky.kappa" value="2.0" lower="0.0"/>
            <stateNode spec='parameter.RealParameter' id="hky.frequencies" value="0.25" dimension="4" lower='0.0'/>
            <stateNode spec='parameter.RealParameter' id="popSize" value="17" lower="0.0"/>
            <stateNode spec='beast.evolution.tree.Tree' id='tree'>
                <taxonset spec='TaxonSet' alignment='@alignment'/>
            </stateNode>
        </state>

        <distribution spec='CompoundDistribution' id='posterior'>
            <distribution spec='CompoundDistribution' id='prior'>
                <distribution id="hky.kappa.prior" spec="beast.math.distributions.Prior" x="@hky.kappa">
                    <distr id="LogNormalDistributionModel" M="1.0" S="1.25" meanInRealSpace="false"
                                  spec="beast.math.distributions.LogNormalDistributionModel"/>
                </distribution>
                <distribution id="hky.frequencies.prior" spec="beast.math.distributions.Prior" x="@hky.frequencies">
                    <distr id="Uniform" lower="0.0" upper="1.0" spec="beast.math.distributions.Uniform"/>
                </distribution>
                <distribution id="popSize.prior" spec="beast.math.distributions.Prior" x="@popSize">
                    <distr id="OneOnX" offset="0.0" spec="beast.math.distributions.OneOnX"/>
                </distribution>

                <distribution id='mrcaPrior1' spec='beast.math.distributions.MRCAPrior' tree='@tree' monophyletic='true'>
                    <taxonset spec='TaxonSet' id='allButSiamang'>
<!--
-->
                        <taxon spec='Taxon' idref='human'/>
                        <taxon spec='Taxon' id='bonobo'/>
                        <taxon spec='Taxon' idref='chimp'/>
                        <taxon spec='Taxon' id='gorilla'/>
                        <taxon spec='Taxon' id='orangutan'/>
                    </taxonset>
                    <distr idref='normalDistr'/>
                </distribution>

                <distribution id='mrcaPrior2' spec='beast.math.distributions.MRCAPrior' tree='@tree' monophyletic='true'>
                    <taxonset spec='TaxonSet' id='human,chimp'>
                        <taxon spec='Taxon' id='human'/>
                        <taxon spec='Taxon' id='chimp'/>
                    </taxonset>
                    <distr id='normalDistr' spec='beast.math.distributions.Normal'>
                        <parameter name='mean' value='6.0'/>
                        <parameter name='sigma' value='0.5'/>
                    </distr>
                </distribution>


                <distribution id="coalescent" spec="Coalescent">
                    <treeIntervals spec='TreeIntervals' id='TreeIntervals'>
                        <tree idref="tree"/>
                    </treeIntervals>
                    <populationModel spec="ConstantPopulation" id='ConstantPopulation'>
                        <parameter name="popSize" idref="popSize"/>
                    </populationModel>
                </distribution>
            </distribution>

            <distribution spec='TreeLikelihood' id="likelihood" data='@alignment' tree='@tree'>
                <siteModel id="siteModel" spec='SiteModel'>
                    <substModel spec='HKY' id="hky">
                        <parameter name='kappa' idref='hky.kappa'/>
                        <frequencies id='freqs' spec='Frequencies' frequencies='@hky.frequencies'/>
                    </substModel>
                </siteModel>
            </distribution>
        </distribution>

        <operator id='kappaScaler' spec='ScaleOperator' scaleFactor="0.75" weight="0.1" parameter="@hky.kappa"/>
        <operator id='frequenciesDelta' spec='DeltaExchangeOperator' delta="0.01" weight="0.1"
                  parameter="@hky.frequencies"/>
        <operator id='popSizeScaler' spec='ScaleOperator' scaleFactor="0.75" weight="3" parameter="@popSize"/>
        <operator id='treeScaler' spec='ScaleOperator' scaleFactor="0.75" weight="3" tree="@tree"/>
        <operator spec='Uniform' weight="30" tree="@tree"/>
        <operator spec='SubtreeSlide' weight="15" gaussian="true" size="1.7" tree="@tree"/>
        <operator id='narrow' spec='Exchange' isNarrow='true' weight="15" tree="@tree"/>
        <operator id='wide' spec='Exchange' isNarrow='false' weight="3" tree="@tree"/>
        <operator spec='WilsonBalding' weight="1" tree="@tree"/>
        <operator spec='UpDownOperator' scaleFactor="0.75" weight="3" down="@tree"/>

        <logger logEvery="1000" fileName="test.$(seed).log">
            <model idref='posterior'/>
            <log idref="posterior"/>
            <log idref="prior"/>
            <log spec='beast.evolution.tree.TreeHeightLogger' tree='@tree'/>
            <log spec='beast.math.distributions.MRCAPrior' tree='@tree' id='HumanChimpMRCA' taxonset='@human,chimp' />
            <log idref="popSize"/>
            <log idref="hky.kappa"/>
            <log idref="hky.frequencies"/>
            <log idref="likelihood"/>
            <log idref="coalescent"/>
        </logger>
        <logger logEvery="1000" fileName="test.$(seed).trees">
            <log idref="tree"/>
        </logger>
        <logger logEvery="100000">
            <model idref='posterior'/>
            <log idref="posterior"/>
            <log idref="prior"/>
            <log spec='beast.evolution.tree.TreeHeightLogger' tree='@tree'/>
            <log idref='HumanChimpMRCA'/>
            <log idref="popSize"/>
            <log idref="hky.kappa"/>
            <log idref="hky.frequencies"/>
            <log idref="likelihood"/>
            <log idref="coalescent"/>
        </logger>
    </run>

</beast>
