<?xml version="1.0" standalone="yes"?>
<!-- test Yule birth model and Birth Death model per Gernhard 2008-->
<beast version='2.0'
       namespace='beast.evolution.speciation:beast.core:beast.evolution.tree.coalescent:beast.core.util:beast.util:beast.evolution.nuc:beast.evolution.operators:beast.evolution.sitemodel:beast.evolution.substitutionmodel:beast.evolution.likelihood'>

    <data id="alignment" dataType="nucleotide">
        <sequence taxon="A">A</sequence>
        <sequence taxon="B">A</sequence>
        <sequence taxon="C">A</sequence>
        <sequence taxon="D">A</sequence>
    </data>
    
    <!-- A prior on the distribution node heights defined given                  -->
    <!-- a Yule speciation process (a pure birth process).                       -->
    <input spec='YuleModel' id="yule">
        <parameter name='birthDiffRate' idref="birthRate"/>
	<tree spec='TreeParser' id='tree' IsLabelledNewick='true' taxa='@alignment'
	        newick='((A:1.0,B:1.0):1.0,(C:1.0,D:1.0):1.0);'/>
    </input>

    <input spec='BirthDeathGernhard08Model' id="yulelike" type='unscaled' tree='@tree'>
        <parameter name='birthDiffRate' idref="birthRate"/>
	    <parameter name='relativeDeathRate' idref='relativeDeathRate'/>
    </input>

    <!-- site model                                                              -->
    <input spec='SiteModel' id="siteModel" gammaCategoryCount='1'>
	<substModel spec='HKY' id='hky'>
	    <kappa id='hky.kappa' spec='parameter.RealParameter' value='1.0'/>
	    <frequencies id='freqs' spec='Frequencies'>
	       <data idref='alignment'/>
	    </frequencies>
	</substModel>
    </input>

    <parameter id="birthRate" value="1.0" lower="0.0" upper="100.0"/>
    <parameter id='relativeDeathRate' value='0'/>

    <!-- initial yule prior = -6.0, yule-like prior = -2.8219461696520542 -->
    <!-- expected yule prior = 1/(n.lambda)\sum_{k=1}^{n-1}k/(n-k) where lambda = birth rate, n = number of taxa
	with lambda=1, n=-4 we expect 1/4(1/3+2/2+3/1)=1.155555555
 -->
    <run spec='MCMC' chainLength="10">
	<state>
	    <stateNode idref='tree'/>
	    <stateNode idref='birthRate'/>
	    <stateNode id='tree-test-single-child-parsing' IsLabelledNewick='true' spec='beast.util.TreeParser' singlechild='true' newick='((A:1.0):2,C:3);' >
			<taxonset spec='beast.evolution.alignment.TaxonSet'>
				<taxon spec='beast.evolution.alignment.Taxon' id='A'/>
				<taxon spec='beast.evolution.alignment.Taxon' id='C'/>
			</taxonset>
		</stateNode>
	</state>

	<distribution spec='CompoundDistribution'>
	        <distribution id="yule.prior" idref='yule'/>
<!--
		<distribution spec='TreeLikelihood' id="treeLikelihood" data='@alignment' tree='@tree' siteModel='@siteModel'/>
-->
	        <distribution id="yulelike.prior" idref='yulelike'/>
	</distribution>

        <operator spec='SubtreeSlide' weight="5" gaussian="true" size="1.0" tree="@tree"/>
<!--
        <operator id='treeScaler' spec='ScaleOperator' scaleFactor="0.5" weight="1" tree="@tree"/>
-->
        <operator spec='Uniform' weight="10" tree="@tree"/>
        <operator id='narrow' spec='Exchange' isNarrow='true' weight="1" tree="@tree"/>
        <operator id='wide' spec='Exchange' isNarrow='false' weight="1" tree="@tree"/>
        <operator spec='WilsonBalding' weight="1" tree="@tree"/>
<!--
        <operator spec='ScaleOperator' scaleFactor="0.75" weight="3">
            <parameter idref="birthRate"/>
        </operator>
-->
	<logger logEvery='100'>
	    <log idref='yule.prior'/>
	    <!--log idref='treeLikelihood'/-->
	    <log idref='yulelike.prior'/>
            <log spec='beast.evolution.tree.TreeHeightLogger' tree='@tree'/>
	</logger>
	<logger logEvery='100' fileName='$(seed).log'>
	    <log idref='yule.prior'/>
	    <!--log idref='treeLikelihood'/-->
	    <!--log idref='yulelike.prior'/-->
            <log spec='beast.evolution.tree.TreeHeightLogger' tree='@tree'/>
	</logger>
    </run>

</beast>
