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

<beast>

        <taxa id="taxa1">
                <taxon id="Human_Horai"/>
                <taxon id="Human_Arnason"/>
                <taxon id="Chimp_Arnason"/>
                <taxon id="Gorilla_Horai"/>
                <taxon id="Gorilla_read1"/>
                <taxon id="Gorilla_read2"/>
                <taxon id="Gorilla_read3"/>
                <taxon id="Chimp_read1"/>
                <taxon id="Chimp_read2"/>
        </taxa>
	<taxa id="referenceTaxa">
                <taxon idref="Human_Horai"/>
                <taxon idref="Human_Arnason"/>
                <taxon idref="Chimp_Arnason"/>
                <taxon idref="Gorilla_Horai"/>
	</taxa>

	<!-- The sequence alignment (each sequence refers to a taxon above).         -->
	<!-- ntax=6 nchar=768                                                        -->
	<alignment id="alignment1" dataType="nucleotide">
		<sequence>
			<taxon idref="Human_Horai"/>
[encoded data, 12638 characters]
          CTCATCCTAACCCTACTCCTAATCACA
            </sequence>
        <sequence>
    <taxon idref="Human_Arnason"/>
[encoded data, 12638 characters]
          CTCATCCTAACCCTACTCCTAATCACA
        </sequence>
        <sequence>
            <taxon idref="Chimp_Arnason"/>
[encoded data, 12638 characters]
          CTCATCTTAACCTTACTCCTAATCACA
        </sequence>
        <sequence>
            <taxon idref="Gorilla_Horai"/>
[encoded data, 12638 characters]
          CTTCTTTTAATCCTTCTTCTAATCACA
        </sequence>
        <sequence>
            <taxon idref="Gorilla_read1"/>
[encoded data, 12638 characters]
          ---------------------------
		</sequence>
        <sequence>
            <taxon idref="Gorilla_read2"/>
[encoded data, 12638 characters]
          ---------------------------
		</sequence>
        <sequence>
            <taxon idref="Gorilla_read3"/>
[encoded data, 12638 characters]
          ---------------------------
		</sequence>
        <sequence>
            <taxon idref="Chimp_read1"/>
[encoded data, 12638 characters]
          ---------------------------
        </sequence>
        <sequence>
            <taxon idref="Chimp_read2"/>
[encoded data, 12638 characters]
          ---------------------------
        </sequence>
	</alignment>


<!--
    <newick id="treeML">
        ((Human_Horai: 0.008514, Human_Arnason: 0.008514): 0.175775, (Chimp_Horai: 0.002462, Chimp_Arnason: 0.002462): 0.181828, (Gorilla_Horai: 0.004522, Gorilla_Arnason: 0.004522): 0.179768);
    </newick>
-->

    <convert id="codonAlignment" dataType="codon" geneticCode="universal">
        <alignment idref="alignment1"/>
    </convert>

     <yangCodonModel id="yang" geneticCode="universal">
        <omega>
            <parameter id="omega" value="1.414"/>
        </omega>
        <kappa>
            <parameter id="kappa" value="1.234567"/>
        </kappa>
        <frequencyModel id="freqmodel" dataType="codon-universal">
            <alignment idref="codonAlignment"/>
            <frequencies>
                <parameter id="codonfrequencies" dimension="61"/>
            </frequencies>
        </frequencyModel>
    </yangCodonModel>

	<metagenomeData id="metagenomeData">
<!--		<tree idref="treeML"/> -->
		<taxa idref="referenceTaxa"/>
		<alignment idref="alignment1"/>
		<!-- any sequence in alignment1 where a corresponding taxon is missing from
			the tree is assumed to be a metagenome read -->
	</metagenomeData>

	<hiddenLinkageModel id="hiddenStrains" linkageGroupCount="3">
<!--		<abundanceDistribution type="uniform"/>
		<readErrorRate value="0.02"/>
-->
		<metagenomeData idref="metagenomeData"/>
	</hiddenLinkageModel>

    <constantSize id="constant" units="substitutions">
        <populationSize>
            <parameter id="constant.popSize" value="0.077" lower="0.0" upper="Infinity"/>
        </populationSize>
    </constantSize>

    <coalescentTree id="startingTree">
	<hiddenLinkageModel idref="hiddenStrains"/>
        <constantSize idref="constant"/>
    </coalescentTree>

	<treeModel id="treeModel1">
		<tree idref="startingTree"/>
		<rootHeight>
			<parameter id="treeModel1.rootHeight"/>
		</rootHeight>
		<nodeHeights internalNodes="true">
			<parameter id="treeModel1.internalNodeHeights"/>
		</nodeHeights>
		<nodeHeights internalNodes="true" rootNode="true">
			<parameter id="treeModel1.allInternalNodeHeights"/>
		</nodeHeights>
	</treeModel>


    <!-- The HKY substitution model (Hasegawa, Kishino & Yano, 1985)             -->
    <hkyModel id="hky">
        <frequencies>
            <frequencyModel dataType="nucleotide">
                <alignment idref="alignment1"/>
                <frequencies>
                    <parameter id="hky.frequencies" dimension="4"/>
                </frequencies>
            </frequencyModel>
        </frequencies>
        <kappa>
            <parameter id="hky.kappa" value="1.0" lower="0.0" upper="Infinity"/>
        </kappa>
    </hkyModel>

    <!-- site model                                                              -->
    <siteModel id="siteModel1">
        <substitutionModel>
            <hkyModel idref="hky"/>
        </substitutionModel>
    </siteModel>

<!--
	<siteModel id="siteModel1">
		<substitutionModel>
			<yangCodonModel idref="yang"/>
		</substitutionModel>
		<mutationRate>
			<parameter id="siteModel1.mu" value="1.0" lower="0.0"/>
		</mutationRate>
	</siteModel>
-->

	<treeLikelihood id="treeLikelihood1">
<!-- hiddenLinkageModel will be parsed as a PatternList and a TipPartialsModel -->
		<hiddenLinkageModel idref="hiddenStrains"/>
		<treeModel idref="treeModel1"/>
		<siteModel idref="siteModel1"/>
	</treeLikelihood>

    <coalescentLikelihood id="coalescent">
        <model>
            <constantSize idref="constant"/>
        </model>
        <populationTree>
            <treeModel idref="treeModel1"/>
        </populationTree>
    </coalescentLikelihood>

    <operators id="operators">
<!-- -->
        <scaleOperator scaleFactor="0.75" weight="1.0">
            <parameter idref="hky.kappa"/>
        </scaleOperator>
<!-- -->
<!--
        <scaleOperator scaleFactor="0.75" weight="1.0">
            <parameter idref="siteModel1.mu"/>
        </scaleOperator>
-->
        <scaleOperator scaleFactor="0.75" weight="3.0">
            <parameter idref="constant.popSize"/>
        </scaleOperator>
        <scaleOperator scaleFactor="0.75" weight="3.0">
            <parameter idref="treeModel1.rootHeight"/>
        </scaleOperator>
        <uniformOperator weight="30.0">
            <parameter idref="treeModel1.internalNodeHeights"/>
        </uniformOperator>
        <subtreeSlide size="0.0077" gaussian="true" weight="15.0">
            <treeModel idref="treeModel1"/>
        </subtreeSlide>
        <narrowExchange weight="15.0">
            <treeModel idref="treeModel1"/>
        </narrowExchange>
        <wideExchange weight="3.0">
            <treeModel idref="treeModel1"/>
        </wideExchange>
        <wilsonBalding weight="3.0">
            <treeModel idref="treeModel1"/>
        </wilsonBalding>
        <moveLinkageGroup weight="3.0">
            <hiddenLinkageModel idref="hiddenStrains"/>
        </moveLinkageGroup>
        <linkageGroupSwap weight="10.0">
            <hiddenLinkageModel idref="hiddenStrains"/>
        </linkageGroupSwap>
    </operators>

    <mcmc id="mcmc" chainLength="10000000" autoOptimize="true">
        <posterior id="posterior">
            <prior id="prior">
                <jeffreysPrior>
                    <parameter idref="hky.kappa"/>
                </jeffreysPrior>
                <jeffreysPrior>
                    <parameter idref="constant.popSize"/>
                </jeffreysPrior>
                <coalescentLikelihood idref="coalescent"/>
            </prior>
            <likelihood id="likelihood">
                <treeLikelihood idref="treeLikelihood1"/>
            </likelihood>
        </posterior>
        <operators idref="operators"/>
        <log id="screenLog" logEvery="10000">
            <column label="Posterior" dp="4" width="12">
                <posterior idref="posterior"/>
            </column>
            <column label="Prior" dp="4" width="12">
                <prior idref="prior"/>
            </column>
            <column label="Likelihood" dp="4" width="12">
                <likelihood idref="likelihood"/>
            </column>
            <column label="Root Height" sf="6" width="12">
                <parameter idref="treeModel1.rootHeight"/>
            </column>
        </log>
        <log id="fileLog" logEvery="1000" fileName="bushSausageUnknown.log">
            <posterior idref="posterior"/>
            <prior idref="prior"/>
            <likelihood idref="likelihood"/>
            <parameter idref="treeModel1.rootHeight"/>
            <parameter idref="constant.popSize"/>
            <parameter idref="hky.kappa"/>
            <treeLikelihood idref="treeLikelihood1"/>
            <coalescentLikelihood idref="coalescent"/>
        </log>
        <logTree id="treeFileLog" logEvery="1000" nexusFormat="true" fileName="bushSausageUnknown.trees"
                 sortTranslationTable="true">
            <treeModel idref="treeModel1"/>
            <posterior idref="posterior"/>
        </logTree>
        <logHiddenLinkageTree id="hiddenLinkageTreeFileLog" logEvery="1000" nexusFormat="true" fileName="bushSausageUnknown.hiddenTrees"
                 sortTranslationTable="true">
            <treeModel idref="treeModel1"/>
            <posterior idref="posterior"/>
	    <hiddenLinkageModel idref="hiddenStrains"/>
        </logHiddenLinkageTree>

	<logHiddenLinkage id="hiddenLinkageFileLog" logEvery="1000" fileName="bushSausageUnknown.linkageGroups">
		<hiddenLinkageModel idref="hiddenStrains"/>
	</logHiddenLinkage>
    </mcmc>
    
</beast>
