<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.likelihood:beast.evolution.alignment'>

    <!-- The simulated sequence alignment. -->
    <data spec='beast.app.seqgen.SimulatedAlignment' id="alignment"
	  sequencelength="2000"
	  outputFileName="simulated_alignment.xml">

      <!-- The true tree down which sequences are simulated. -->
      <tree spec='beast.util.TreeParser'
	    newick="((((human:0.021044961362048316,(chimp:0.01010430475937982,bonobo:0.01010430475937982):0.010940656602668497):0.012937366252643932,gorilla:0.03398232761469225):0.019356330316295488,orangutan:0.053338657930987736):0.011836836575646971,siamang:0.0651754945066347):0.0"
	    IsLabelledNewick="true"/>

      <data spec='Alignment' id="input_alignment" dataType="nucleotide">
        <sequence spec='Sequence' taxon="human" value="?"/>
        <sequence spec='Sequence' taxon="chimp" value="?"/>
        <sequence spec='Sequence' taxon="bonobo" value="?"/>
        <sequence spec='Sequence' taxon="gorilla" value="?"/>
        <sequence spec='Sequence' taxon="orangutan" value="?"/>
        <sequence spec='Sequence' taxon="siamang" value="?"/>
      </data>

      <siteModel spec="SiteModel" id="trueSiteModel" mutationRate="0.005">
	<substModel spec="JukesCantor"/>
      </siteModel>
      
    </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='TreeLikelihood' id="treeLikelihood">
        <input name='data' idref="alignment"/>
        <input name='tree' idref="tree"/>
        <input name='siteModel' idref="siteModel"/>
    </input>


    <input spec='beast.util.ClusterTree' id='tree' clusterType='upgma'>
        <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='tree'/>
        </state>

        <distribution spec="CompoundDistribution" id="posterior">
            <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 id='likelihood' idref="treeLikelihood"/>
        </distribution>

        <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="10000" fileName="test.$(seed).log">
   	        <model idref='posterior'/>
            <log idref="coalescent"/>
            <log idref="likelihood"/>
            <!--parameter idref="treeModel.rootHeight"/-->
            <log idref="popSize"/>
            <log idref="hky.kappa"/>
            <log idref="posterior"/>
        </logger>
        <logger logEvery="10000" fileName="test.$(seed).trees">
            <log idref="tree"/>
        </logger>
        <logger logEvery="10000">
	        <model idref='posterior'/>
            <log idref="coalescent"/>
            <log idref="likelihood"/>
            <!--parameter idref="treeModel.rootHeight"/-->
            <log idref="popSize"/>
            <log idref="hky.kappa"/>
            <log idref="posterior"/>
        </logger>
    </run>

</beast>
