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


    <!-- The sequence alignment (each sequence refers to a taxon above).         -->
    <!-- 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>

    <!-- The HKY substitution model (Hasegawa, Kishino & Yano, 1985)             -->
    <input spec='HKY' id="hky">
        <parameter name='kappa' idref='hky.kappa'/>
        <input id='freqs' name='frequencies' spec='Frequencies'>
            <input name='data' idref='alignment'/>
        </input>
    </input>

    <!-- site model                                                              -->
    <input spec='SiteModel' id="siteModel">
        <!--<parameter name='mutationRate'>1.0</parameter>-->
        <input name='substModel' idref='hky'/>
    </input>


    <input spec='UCRelaxedClockModel' id="branchRates" normalize='true'>
        <!--<parameter name='mutationRate'>1.0</parameter>-->
		<parameter name='clock.rate' id='ucld.mean' value='1.0'/>
        <distr id='lognormal' spec="beast.math.distributions.LogNormalDistributionModel">
            <parameter name='M' id='M' value="1"/>
            <parameter name='S' id='ucld.stdev' value="0.5" lower="0" upper="5"/>
        </distr>
        <parameter spec='IntegerParameter' name='rateCategories' id='rateCategories' dimension="11" value="1"/>
        <input name='tree' idref="tree"/>
    </input>

    <input spec='TreeLikelihood' id="treeLikelihood">
        <input name='data' idref="alignment"/>
        <input name='tree' idref="tree"/>
        <input name='siteModel' idref="siteModel"/>
        <input name="branchRateModel" idref="branchRates"/>
    </input>

    <input spec='beast.util.ClusterTree' id='tree' clusterType='upgma'>
	<!--trait idref='rateCategories'/--> 
        <input name='taxa' idref='alignment'/>
    </input>

    <input spec='beast.core.parameter.RealParameter' id="hky.kappa">1.0</input>

    <input spec='beast.core.parameter.RealParameter' id="popSize">1.0</input>


    <run spec="MCMC" id="mcmc" chainLength="1000000"> <!--autoOptimize="true"-->
        <state>
            <input name='stateNode' idref='hky.kappa'/>
            <input name='stateNode' idref='popSize'/>
            <input name='stateNode' idref='ucld.mean'/>
            <input name='stateNode' idref='ucld.stdev'/>
            <input name='stateNode' idref='tree'/>
            <input name='stateNode' idref='rateCategories'/>
        </state>

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

        <operator id="categoriesRandomWalk" spec="UniformOperator" weight="1">
            <input name="parameter" idref="rateCategories"/>
        </operator>

        <operator id='SScaler' spec='ScaleOperator' scaleFactor="0.5" weight="1" parameter='@ucld.stdev'/>

        <operator id='kappaScaler' spec='ScaleOperator' scaleFactor="0.5" weight="1">
            <parameter idref="hky.kappa"/>
        </operator>
        <operator id='popSizeScaler' spec='ScaleOperator' scaleFactor="0.5" weight="1">
            <parameter idref="popSize"/>
        </operator>
        <operator id='treeScaler' spec='ScaleOperator' scaleFactor="0.5" weight="1">
            <tree idref="tree"/>
        </operator>
        <operator spec='Uniform' weight="10">
            <tree idref="tree"/>
        </operator>
        <operator spec='SubtreeSlide' weight="5" gaussian="true" size="1.0">
            <tree idref="tree"/>
        </operator>
        <operator id='narrow' spec='Exchange' isNarrow='true' weight="1">
            <tree idref="tree"/>
        </operator>
        <operator id='wide' spec='Exchange' isNarrow='false' weight="1">
            <tree idref="tree"/>
        </operator>
        <operator spec='WilsonBalding' weight="1">
            <tree idref="tree"/>
        </operator>

        <logger logEvery="1000" fileName="test.$(seed).log">
	    <model idref='posterior'/>
            <log idref="coalescent"/>
            <log idref="likelihood"/>
            <log spec='beast.evolution.tree.TreeHeightLogger'>
                <tree idref='tree'/>
            </log>
            <log idref="popSize"/>
            <log idref="hky.kappa"/>
            <log idref="ucld.stdev"/>
            <log idref="rateCategories"/>
            <log idref="posterior"/>
        </logger>
        <logger logEvery="1000" fileName="test.(time).$(seed).trees" mode='tree'>
			<log spec='beast.evolution.tree.TreeWithMetaDataLogger' tree='@tree' dp='6'>
				<branchratemodel idref='branchRates'/>
			</log>
        </logger>
        <logger logEvery="1000" fileName="test.(subst).$(seed).trees" mode='tree'>
			<log spec='beast.evolution.tree.TreeWithMetaDataLogger' tree='@tree' substitutions='true' dp='6'>
				<branchratemodel idref='branchRates'/>
			</log>
        </logger>
        <logger logEvery="10000">
	    <model idref='posterior'/>
            <log idref="coalescent"/>
            <log idref="likelihood"/>
            <log spec='beast.evolution.tree.TreeHeightLogger'>
                <tree idref='tree'/>
            </log>
            <log idref="popSize"/>
            <log idref="hky.kappa"/>
            <log idref="ucld.stdev"/>
            <!--log idref="rateCategories"/-->
            <log idref="posterior"/>
        </logger>
    </run>

</beast>
