<beast version='2.0'
       namespace='beast.app.beauti:beast.core:beast.evolution.branchratemodel:beast.evolution.speciation:beast.evolution.tree.coalescent:beast.core.util:beast.evolution.nuc:beast.evolution.operators:beast.evolution.sitemodel:beast.evolution.substitutionmodel:beast.evolution.likelihood:beast.evolution:beast.math.distributions'
	templateinfo='*BEAST species tree reconstruction from multiple-genes&lt;br>(calibrations supported, but tip-dates are not)'>


<map name='connect' reserved='true'>beast.app.beauti.BeautiConnector</map>
<map name='subtemplate' reserved='true'>beast.app.beauti.BeautiSubTemplate</map>
<map name='Uniform'>beast.math.distributions.Uniform</map>
<map name='Normal'>beast.math.distributions.Normal</map>
<map name='OneOnX'>beast.math.distributions.OneOnX</map>
<map name='LogNormal'>beast.math.distributions.LogNormalDistributionModel</map>
<map name='Exponential'>beast.math.distributions.Exponential</map>
<map name='Gamma'>beast.math.distributions.Gamma</map>
<map name='Beta'>beast.math.distributions.Beta</map>
<map name='LaplaceDistribution'>beast.math.distributions.LaplaceDistribution</map>
<map name='InverseGamma'>beast.math.distributions.InverseGamma</map>
<map name='prior'>beast.math.distributions.Prior</map>

    <beauticonfig spec='BeautiConfig'
        inputLabelMap='beast.core.MCMC.operator=Operators,
	        beast.core.MCMC.logger=Loggers,
			beast.evolution.sitemodel.SiteModel.mutationRate =Substitution Rate,
			beast.evolution.speciation.SpeciesTreePrior.gammaParameter=Population Mean'
        inlinePlugins ='beast.core.MCMC.distribution,
            beast.evolution.sitemodel.SiteModel.substModel,
            beast.evolution.tree.coalescent.ExponentialGrowth,
            beast.evolution.tree.coalescent.ConstantPopulation,
            beast.evolution.tree.coalescent.Coalescent,
            beast.core.State.stateNode'
        collapsedPlugins ='beast.core.MCMC.logger'
        suppressPlugins = 'beast.core.MCMC.operator,
		beast.core.MCMC.operatorschedule,
	        beast.evolution.tree.coalescent.Coalescent.treeIntervals,
	        beast.evolution.tree.coalescent.Coalescent.tree,
	        beast.core.MCMC.state,
	        beast.core.MCMC.distribution,
	        beast.core.MCMC.init,
	        beast.evolution.speciation.BirthDeathGernhard08Model.relativeDeathRate,
	        beast.evolution.speciation.BirthDeathGernhard08Model.treeIntervals,
	        beast.evolution.speciation.BirthDeathGernhard08Model.type,
	        beast.evolution.speciation.BirthDeathGernhard08Model.sampleProbability,
	        beast.evolution.speciation.BirthDeathGernhard08Model.tree,
	        beast.evolution.tree.Tree,
	        beast.evolution.tree.Tree.trait,
	        beast.evolution.tree.Tree.taxa,
	        beast.evolution.tree.Tree.taxonset,
	        beast.evolution.tree.RandomTree.trait,
	        beast.evolution.tree.RandomTree.initial,
	        beast.evolution.tree.RandomTree.taxa,
	        beast.evolution.tree.RandomTree.taxonset,
	        beast.evolution.tree.RandomTree.estimate,
	        beast.util.TreeParser.initial,
	        beast.util.TreeParser.taxa,
	        beast.util.TreeParser.taxonset,
	        beast.util.TreeParser.trait,
	        beast.util.TreeParser.estimate,
	        beast.util.ClusterTree.initial,
	        beast.util.ClusterTree.taxa,
	        beast.util.ClusterTree.taxonset,
	        beast.util.ClusterTree.trait,
	        beast.util.ClusterTree.estimate,
	        beast.evolution.substitutionmodel.WAG.rates,
	        beast.evolution.substitutionmodel.WAG.frequencies,
	        beast.evolution.substitutionmodel.JTT.rates,
	        beast.evolution.substitutionmodel.JTT.frequencies,
	        beast.evolution.substitutionmodel.Blosum62.rates,
	        beast.evolution.substitutionmodel.Blosum62.frequencies,
	        beast.evolution.substitutionmodel.Dayhoff.rates,
	        beast.evolution.substitutionmodel.Dayhoff.frequencies,
	        beast.evolution.substitutionmodel.CPREV.rates,
	        beast.evolution.substitutionmodel.CPREV.frequencies,
	        beast.evolution.substitutionmodel.MTREV.rates,
	        beast.evolution.substitutionmodel.MTREV.frequencies,
	        beast.evolution.substitutionmodel.GTR.rates,
	        beast.evolution.substitutionmodel.JukesCantor.frequencies,
            beast.math.distributions.Prior.x,
            beast.math.distributions.MRCAPrior.tree,
            beast.math.distributions.MRCAPrior.monophyletic,
            beast.math.distributions.MRCAPrior.taxonset,
            beast.evolution.branchratemodel.UCRelaxedClockModel.tree,
            beast.evolution.branchratemodel.UCRelaxedClockModel.rateCategories,
            beast.evolution.branchratemodel.RandomLocalClockModel.tree,
            beast.evolution.branchratemodel.RandomLocalClockModel.meanRate,
            beast.evolution.branchratemodel.RandomLocalClockModel.indicators,
            beast.evolution.operators.ScaleOperator.indicator,
	        beast.core.Operator.weight,
			beast.evolution.speciation.GeneTreeForSpeciesTreeDistribution.speciesTree,
			beast.evolution.speciation.GeneTreeForSpeciesTreeDistribution.speciesTreePrior,
			beast.evolution.speciation.GeneTreeForSpeciesTreeDistribution.treetop,
			beast.evolution.speciation.GeneTreeForSpeciesTreeDistribution.tree,
			beast.evolution.speciation.GeneTreeForSpeciesTreeDistribution.treeIntervals,
			beast.evolution.speciation.SpeciesTreePrior.bottomPopSize,
			beast.evolution.speciation.SpeciesTreePrior.topPopSize,
			beast.evolution.speciation.SpeciesTreePrior.taxonset,
			beast.evolution.speciation.SpeciesTreePrior.tree,
			beast.evolution.speciation.SpeciesTreePrior.treeIntervals,
			beast.evolution.speciation.YuleModel.treeIntervals,
			beast.evolution.speciation.YuleModel.useTipDates,
			beast.evolution.speciation.YuleModel.tree,
            beast.core.Logger.model
            '
        buttonLabelMap='beast.app.beauti.BeautiInitDlg.&gt;&gt; details=Edit parameters'
    >


        <panel spec='BeautiPanelConfig' panelname="Partitions" tiptext="Data Partitions"
            path='distribution/distribution[id="likelihood"]/distribution/data'
            hasPartitions="none" icon='2220.pngx' forceExpansion='FALSE'
            type='beast.evolution.alignment.Alignment'
        />
		<mergepoint id='aux-partitions-panels'/>

		<panel spec='BeautiPanelConfig' panelname="Taxon sets" tiptext="Specify taxon sets that make up species"
            path='distribution/distribution[id="speciescoalescent"]/distribution[id="SpeciesTreePopSize.Species"]/taxonset'
            hasPartitions="none" icon='1.pngx' forceExpansion='TRUE'
        />
		<panel spec='BeautiPanelConfig' panelname="Site Model" tiptext="Site model and substitution model specifications"
            path='siteModel'
            hasPartitions="SiteModel" icon='3.pngx' forceExpansion='TRUE'
        />
		<mergepoint id='aux-sitemodel-panels'/>

		<panel spec='BeautiPanelConfig' panelname="Clock Model" tiptext="Clock model"
            path='branchRateModel'
            hasPartitions="ClockModel" icon='4.pngx' forceExpansion='TRUE'
        />
		<mergepoint id='aux-clockmodel-panels'/>

		<panel spec='BeautiPanelConfig' panelname="Initialization" tiptext="Initial state"
            path='state/stateNode'
            hasPartitions="none" icon='6.pngx' forceExpansion='TRUE_START_COLLAPSED'
            isVisible='false'
        />
		<mergepoint id='aux-initilisation-panels'/>

		<panel spec='BeautiPanelConfig' panelname="Multi Species Coalescent" tiptext="Multi Species Coalescent specific settings"
            path='distribution/distribution[id="speciescoalescent"]/distribution'
            hasPartitions="none" icon='2.pngx' forceExpansion='TRUE'
        />

		<panel spec='BeautiPanelConfig' panelname="Priors" tiptext="Other priors"
            path='distribution/distribution[id="prior"]/distribution'
            hasPartitions="none" icon='7.pngx' forceExpansion='TRUE_START_COLLAPSED'
            type='beast.core.Distribution'  buttonStatus='ADD_ONLY'
        />
		<mergepoint id='aux-priors-panels'/>

		<panel spec='BeautiPanelConfig' panelname="Operators" tiptext="MCMC Operator details"
            path='operator'
            hasPartitions="none" icon='8.pngx' forceExpansion='TRUE_START_COLLAPSED'
            isVisible='false'
        />
		<mergepoint id='aux-operators-panels'/>

		<panel spec='BeautiPanelConfig' panelname="MCMC" tiptext="MCMC parameters"
            path=''
            hasPartitions="none" icon='9.pngx' forceExpansion='TRUE'
        />
		<mergepoint id='aux-panels'/>

		<alignmentProvider id="Import Alignment" spec='BeautiAlignmentProvider' template='@StarBEASTPartitionTemplate'/>


        <partitiontemplate id='StarBEASTPartitionTemplate' spec='BeautiSubTemplate' class='beast.evolution.likelihood.ThreadedTreeLikelihood' mainid='mcmc'>
<![CDATA[

		    <distribution id='treePrior.t:$(n)' spec='GeneTreeForSpeciesTreeDistribution' tree='@Tree.t:$(n)' speciesTree='@Tree.t:Species' speciesTreePrior='@SpeciesTreePopSize.Species'/>

            <!-- site model                                                              -->
            <plugin spec='SiteModel' id="SiteModel.s:$(n)" gammaCategoryCount='0'>
                <!--substModel will be automatically detected /-->
                <proportionInvariant spec='parameter.RealParameter' id='proportionInvariant.s:$(n)' value='0.0' lower='0' upper='1' estimate='false'/>
                <mutationRate        spec='parameter.RealParameter' id='mutationRate.s:$(n)' value='1.0'        estimate='false'/>
                <shape               spec='parameter.RealParameter' id='gammaShape.s:$(n)' value='1.0'         estimate='false'/>
            </plugin>

            <plugin spec='TreeLikelihood' id="treeLikelihood.$(n)">
                <data idref="data"/>
                <tree idref="Tree.t:$(n)"/>
                <siteModel idref="SiteModel.s:$(n)"/>
                <branchRateModel spec='StrictClockModel' id='StrictClock.c:$(n)'>
                    <clock.rate id='clockRate.c:$(n)' spec='parameter.RealParameter' value='1.0' estimate='false'/>
                </branchRateModel>
            </plugin>

	        <prior id='ClockPrior.c:$(n)' x='@clockRate.c:$(n)'><distr spec="beast.math.distributions.Uniform" upper='Infinity'/></prior>
	        <prior id='MutationRatePrior.s:$(n)' x='@mutationRate.s:$(n)'><distr spec="OneOnX"/></prior>

            <!-- tree and its properties -->
            <taxonset id='TaxonSet.$(n)' spec='beast.evolution.alignment.TaxonSet' alignment='@$(n)' />
            <plugin spec='beast.evolution.tree.Tree' id='Tree.t:$(n)' taxonset='@TaxonSet.$(n)'/>

            <!--plugin spec='beast.evolution.tree.RandomTree' id='RandomTree.t:$(n)' estimate='false' trait='@datetrait.$(n)' initial='@Tree.t:$(n)'-->
			<tree spec='RandomGeneTree' id='RandomGeneTree.t:$(n)' initial='@Tree.t:$(n)' speciesTree='@Tree.t:Species' taxa='@$(n)'>
				<populationModel id='RGTPopulationModel.t:$(n)' spec='ConstantPopulation'>
					<popSize id='RGTPopSize.t:$(n)' spec='parameter.RealParameter' value='1'/>
				</populationModel>
			</tree>

            <plugin id='TreeHeight.t:$(n)' spec='beast.evolution.tree.TreeHeightLogger' tree='@Tree.t:$(n)'/>

            <logger id='treelog.t:$(n)' spec='beast.core.Logger' logEvery="5000" fileName="$(tree).trees" mode='tree'>
	            <log id='TreeWithMetaDataLogger.t:$(n)' spec='beast.evolution.tree.TreeWithMetaDataLogger' tree='@Tree.t:$(n)'>
	            </log>
            </logger>

            <operator id='proportionInvariantScaler.s:$(n)' spec='ScaleOperator' scaleFactor="0.5" weight="0.5" parameter="@proportionInvariant.s:$(n)"/>
            <operator id='mutationRateScaler.s:$(n)' spec='ScaleOperator' scaleFactor="0.5" weight="0.5" parameter="@mutationRate.s:$(n)"/>
            <operator id='gammaShapeScaler.s:$(n)' spec='ScaleOperator' scaleFactor="0.5" weight="0.5" parameter="@gammaShape.s:$(n)"/>

            <operator id='treeScaler.t:$(n)' spec='ScaleOperator' scaleFactor="0.5" weight="3" tree="@Tree.t:$(n)"/>
            <operator id='treeRootScaler.t:$(n)' spec='ScaleOperator' scaleFactor="0.5" weight="3" tree="@Tree.t:$(n)" rootOnly='true'/>
            <operator id='UniformOperator.t:$(n)' spec='Uniform' weight="30" tree="@Tree.t:$(n)"/>
            <operator id='SubtreeSlide.t:$(n)' spec='SubtreeSlide' weight="15" gaussian="true" size="1.0" tree="@Tree.t:$(n)"/>
            <operator id='narrow.t:$(n)' spec='Exchange' isNarrow='true' weight="15" tree="@Tree.t:$(n)"/>
            <operator id='wide.t:$(n)' spec='Exchange' isNarrow='false' weight="3" tree="@Tree.t:$(n)"/>
            <operator id='WilsonBalding.t:$(n)' spec='WilsonBalding' weight="3" tree="@Tree.t:$(n)"/>

            <operator id='updown.$(n)' spec='UpDownOperator' scaleFactor="0.75" weight="3">
                <up idref="clockRate.c:$(n)"/>
                <down idref="Tree.t:$(n)"/>
            </operator>

            <prior id='GammaShapePrior.s:$(n)' x='@gammaShape.s:$(n)'><distr spec="beast.math.distributions.Exponential" mean='1'/></prior>
            <prior id='PropInvariantPrior.t:$(n)' x='@proportionInvariant.s:$(n)'><distr spec="beast.math.distributions.Uniform" lower='0' upper='1'/></prior>
			<operator id='StrictClockRateScaler.c:$(n)' spec='ScaleOperator' scaleFactor="0.75" weight="3" parameter='@clockRate.c:$(n)'/>
			<!-- need updown operator for clockRate?!? Also in SubstModel.xml -->


]]>
            <connect srcID='treeLikelihood.$(n)'         targetID='likelihood' inputName='distribution' if="isInitializing"/>
            <!-- for backward compatibility when loading pre v2.4.4 XML -->	
			<connect srcID="operatorSchedule"            targetID="mcmc" inputName="operatorschedule" if="inposterior(Tree.t:Species)"/>

            <connect srcID='treelog.t:$(n)'              targetID='mcmc' inputName='logger' if='inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'/>

            <connect srcID='treePrior.t:$(n)'            targetID='speciescoalescent' inputName='distribution' if='inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'/>
<!-- trick to ensure that treePrior.$(n) is always deleted from prior, since it is already part of speciescoalescent -->
            <connect srcID='treePrior.t:$(n)'            targetID='prior' inputName='distribution' if='Tree.t:$(n)/estimate=nonsense'/>

            <connect srcID='ClockPrior.c:$(n)'           targetID='prior' inputName='distribution' if='inposterior(clockRate.c:$(n)) and clockRate.c:$(n)/estimate=true'/>
<!-- when FixMeanMutationRatesOperator, the prior is uniform due to the operator -->
            <connect srcID='MutationRatePrior.s:$(n)'    targetID='prior' inputName='distribution' if='nooperator(FixMeanMutationRatesOperator) and inposterior(mutationRate.s:$(n)) and mutationRate.s:$(n)/estimate=true'/>

            <connect srcID='Tree.t:$(n)'                 targetID='state' inputName='stateNode' if='inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'/>
            <connect srcID='proportionInvariant.s:$(n)'  targetID='state' inputName='stateNode' if='inposterior(proportionInvariant.s:$(n)) and proportionInvariant.s:$(n)/estimate=true'/>
            <connect srcID='mutationRate.s:$(n)'         targetID='state' inputName='stateNode' if='inposterior(mutationRate.s:$(n)) and mutationRate.s:$(n)/estimate=true'/>
            <connect srcID='gammaShape.s:$(n)'           targetID='state' inputName='stateNode' if='inposterior(gammaShape.s:$(n)) and gammaShape.s:$(n)/estimate=true'/>
            <connect srcID='clockRate.s:$(n)'            targetID='state' inputName='stateNode' if='inposterior(clockRate.s:$(n)) and clockRate.s:$(n)/estimate=true'/>

            <connect srcID='proportionInvariantScaler.s:$(n)' targetID='mcmc' inputName='operator' if='inposterior(proportionInvariant.s:$(n)) and proportionInvariant.s:$(n)/estimate=true'/>
            <connect srcID='mutationRateScaler.s:$(n)'        targetID='mcmc' inputName='operator' if='nooperator(FixMeanMutationRatesOperator) and inposterior(mutationRate.s:$(n)) and mutationRate.s:$(n)/estimate=true'/>
            <connect srcID='gammaShapeScaler.s:$(n)'          targetID='mcmc' inputName='operator' if='inposterior(gammaShape.s:$(n)) and gammaShape.s:$(n)/estimate=true'/>
            <connect srcID='StrictClockRateScaler.c:$(n)'     targetID='mcmc' inputName='operator' if='inposterior(clockRate.c:$(n)) and clockRate.c:$(n)/estimate=true'/>

            <connect srcID='treeScaler.t:$(n)'                targetID='mcmc' inputName='operator' if='inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'/>
            <connect srcID='treeRootScaler.t:$(n)'            targetID='mcmc' inputName='operator' if='inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'>Scales root node for tree t:$(n)</connect>
            <connect srcID='UniformOperator.t:$(n)'           targetID='mcmc' inputName='operator' if='inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'/>
            <connect srcID='SubtreeSlide.t:$(n)'              targetID='mcmc' inputName='operator' if='inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'/>
            <connect srcID='narrow.t:$(n)'                    targetID='mcmc' inputName='operator' if='inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'/>
            <connect srcID='wide.t:$(n)'                      targetID='mcmc' inputName='operator' if='inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'/>
            <connect srcID='WilsonBalding.t:$(n)'             targetID='mcmc' inputName='operator' if='inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'/>
            <connect srcID='updown.$(n)'                      targetID='mcmc' inputName='operator' if='nooperator(FixMeanRatesOperator) and inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true and inlikelihood(clockRate.c:$(n)) and clockRate.c:$(n)/estimate=true'/>

            <connect srcID='treeLikelihood.$(n)'         targetID='tracelog' inputName='log' if='inlikelihood(treeLikelihood.$(n))'/>
            <connect srcID='treePrior.t:$(n)'            targetID='tracelog' inputName='log' if='inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'/>
            <connect srcID='TreeHeight.t:$(n)'           targetID='tracelog' inputName='log' if='inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'/>
            <connect srcID='proportionInvariant.s:$(n)'  targetID='tracelog' inputName='log' if='inlikelihood(proportionInvariant.s:$(n)) and proportionInvariant.s:$(n)/estimate=true'/>
            <connect srcID='mutationRate.s:$(n)'         targetID='tracelog' inputName='log' if='inlikelihood(mutationRate.s:$(n)) and mutationRate.s:$(n)/estimate=true'/>
            <connect srcID='gammaShape.s:$(n)'           targetID='tracelog' inputName='log' if='inlikelihood(gammaShape.s:$(n)) and gammaShape.s:$(n)/estimate=true'/>
            <connect srcID='clockRate.c:$(n)'            targetID='tracelog' inputName='log' if='inlikelihood(clockRate.c:$(n)) and clockRate.c:$(n)/estimate=true'/>

            <connect srcID='GammaShapePrior.s:$(n)'      targetID='prior' inputName='distribution' if='inlikelihood(gammaShape.s:$(n)) and gammaShape.s:$(n)/estimate=true'/>
            <connect srcID='PropInvariantPrior.s:$(n)'   targetID='prior' inputName='distribution' if='inlikelihood(proportionInvariant.s:$(n)) and proportionInvariant.s:$(n)/estimate=true'/>
            <connect srcID='Tree.t:$(n)'        targetID='Reheight.t:Species' inputName='genetree' if='Tree.t:$(n)/estimate=true'/>

	        <connect srcID='Tree.t:$(n)'        targetID='updown.all.Species' inputName='down' if='inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'/>
	        <connect srcID='clockRate.c:$(n)'   targetID='updown.all.Species' inputName='up' if='nooperator(FixMeanRatesOperator) and inlikelihood(clockRate.c:$(n)) and clockRate.c:$(n)/estimate=true'/>

	        <connect srcID='popSizeTop' targetID='updown.all.Species' inputName='down' if='SpeciesTreePopSize.Species/popFunction!=constant'/>

            <connect srcID='popSizeTopScaler.t:Species' targetID='mcmc'  inputName='operator' if='SpeciesTreePopSize.Species/popFunction!=constant'/>
            <connect srcID='popSizeTop'       targetID='state' inputName='stateNode' if='SpeciesTreePopSize.Species/popFunction!=constant'/>
            <connect srcID='popSizeTop'       targetID='SpeciesTreePopSize.Species' inputName='topPopSize' if='SpeciesTreePopSize.Species/popFunction!=constant'/>
            <connect srcID='popSizeTop'       targetID='SpeciesTreeLoggerX' inputName='popSizeTop' if='SpeciesTreePopSize.Species/popFunction!=constant'/>

            <connect srcID='Tree.t:$(n)'      targetID='treeTopFinder' inputName='tree' if='inposterior(Tree.t:$(n)) and Tree.t:$(n)/estimate=true'/>
            <connect srcID='treeTopFinder'    targetID='treePrior.t:$(n)' inputName='treetop' if='SpeciesTreePopSize.Species/popFunction=linear'/>
			<!-- 
			Since 'Species' is treated as a separate partition, we need the following
			hack to get rid of undesirable Tree.t:Species connections 
			-->
            <connect srcID='Tree.t:Species'     targetID='Reheight.t:Species' inputName='genetree' if='Tree.t:$(n)/estimate=XXX'/>
            <connect srcID='Tree.t:Species'     targetID='treeTopFinder' inputName='tree' if='Tree.t:$(n)/estimate=XXX'/>

			<connect srcID='birthRate.t:Species' targetID='updown.all.Species' inputName='up' if='inposterior(birthRate.t:Species)'/>
	

            <!-- initialise species and gene trees: if CalibratedYuleModel is used, 
                use the old initialisation, otherwise use the fancy new SBI -->
			<connect srcID="SBI"                           targetID='mcmc' inputName='init' if='nooperator(CalibratedYuleBirthRateScaler.t:$(n))'/>
			<!-- gene tree initialiser by SBI -->
            <connect srcID='Tree.t:$(n)'                   targetID='SBI' inputName='gene' if='inposterior(Tree.t:$(n))'/>
			<!-- we don't want Tree.t:Species to be treated as gene, so the condition is guaranteed false -->
            <connect srcID='Tree.t:Species'                targetID='SBI' inputName='gene' if='popSize/value=-1'/>
            <connect srcID='Tree.t:Species'                targetID='SBI' inputName='speciesTree' if='inposterior(Tree.t:Species) and nooperator(CalibratedYuleBirthRateScaler.t:$(n))'/>
			<connect srcID="CalibratedYuleModel.t:Species" targetID='SBI' inputName='calibratedYule' if='inposterior(CalibratedYuleModel.t:Species)'/>


			<connect srcID="RandomTree.t:Species"          targetID='mcmc' inputName='init' if='inposterior(CalibratedYuleModel.t:Species)'/>
            <connect srcID='RandomGeneTree.t:$(n)'         targetID='mcmc' inputName='init' if='inposterior(Tree.t:$(n)) and inposterior(CalibratedYuleModel.t:Species)'/>



			<mergepoint id='aux-partitiontemplate'/>
        </partitiontemplate>

		<mergepoint id='substModelTemplates'/>
		<mergepoint id='clockModelTemplates'/>
		<mergepoint id='treePriorTemplates'/>
        <mergepoint id='parametricDistributions'/>

    </beauticonfig>

	<mergepoint id='misc'/>

	<taxonset spec='beast.evolution.alignment.TaxonSet' id='taxonsuperset'>
		<!-- 
		need to specify at least one taxon for a TaxonSet, so insert a dummy taxon here
		This one is cleared by the TaxonSetInputEditor 
		-->
		<taxon spec='beast.evolution.alignment.TaxonSet' id='Beauti2DummyTaxonSet'>
			<taxon spec='beast.evolution.alignment.Taxon' id='dummyTaxon'/>
		</taxon>
	</taxonset>

	<tree spec='beast.evolution.tree.Tree' id='Tree.t:Species' taxonset='@taxonsuperset' estimate='true'/>

	<treetop spec='TreeTopFinder' id='treeTopFinder'/>

<!-- framework for main model -->
    <run spec="MCMC" id="mcmc" storeEvery="5000" chainLength="10000000">
    	<operatorschedule id="operatorSchedule" spec="OperatorSchedule">
    		<!-- assign 20% of all weight to operators that apply to the Species partition -->
    		<subschedule id="operatorSubschedule" spec="OperatorSchedule" weight="20" weightIsPercentage="true" operatorPattern="^.*Species$"/>
    	</operatorschedule>

        <state storeEvery='5000' id='state'>
	        <stateNode idref='popSize'/> 
	        <stateNode idref='popSizeTop'/> 
	        <stateNode idref='Tree.t:Species'/> 
	        <stateNode idref='birthRate.t:Species'/> 
	        <stateNode idref='popMean'/> 
        </state>

        <distribution spec="CompoundDistribution" id="posterior">
            <distribution spec="CompoundDistribution" id="speciescoalescent">
				<distribution id='SpeciesTreePopSize.Species' spec='SpeciesTreePrior' tree='@Tree.t:Species' 
						popFunction='constant' taxonset='@taxonsuperset'>
				    <bottomPopSize spec='parameter.RealParameter' id='popSize' value='1'/> 
			        <topPopSize spec='parameter.RealParameter' id='popSizeTop' value='1'/> 
				    <parameter name='gammaParameter' id='popMean' value='1' estimate="true"/>
				</distribution>
				<mergepoint id='aux-priors'/>
			</distribution>
            <distribution spec="CompoundDistribution" id="prior">
			    <!-- species tree priors -->
		        <distribution id="YuleModel.t:Species" spec="speciation.YuleModel" tree='@Tree.t:Species'>
		            <birthDiffRate spec='parameter.RealParameter' id="birthRate.t:Species" value='1' lower='0' />
		        </distribution>
	            <distribution id='YuleBirthRatePrior.t:Species' spec='beast.math.distributions.Prior' x='@birthRate.t:Species'>
		             <distr spec="beast.math.distributions.OneOnX"/>
		        </distribution>
	            <distribution id='popMean.prior' spec='beast.math.distributions.Prior' x='@popMean'>
		            <distr spec="beast.math.distributions.OneOnX"/>
		        </distribution>
            </distribution>
            <distribution spec="CompoundDistribution" id="likelihood" useThreads="true">
				<mergepoint id='aux-likelihoods'/>
            </distribution>
        </distribution>

	    <operator id="Reheight.t:Species" spec="NodeReheight" tree="@Tree.t:Species" weight="94" taxonset='@taxonsuperset'/>
	    <operator degreesOfFreedom="1" id="popSizeBottomScaler.t:Species" scaleAll="false" scaleAllIndependently="false" scaleFactor="0.5" spec="ScaleOperator" parameter="@popSize" weight="5.0"/>
	    <operator degreesOfFreedom="1" id="popSizeTopScaler.t:Species" scaleAll="false" scaleAllIndependently="false" scaleFactor="0.5" spec="ScaleOperator" parameter="@popSizeTop" weight="5.0"/>
	    <operator id='popMeanScale.t:Species' spec='ScaleOperator' scaleFactor="0.75" weight="3" parameter="@popMean"/>

	    <operator id="updown.all.Species" spec='UpDownOperator' scaleFactor="0.75" weight="20">
	      <up idref="birthRate.t:Species"/>
	      <down idref="popMean"/>
	      <down idref="popSize"/>

	      <down idref="Tree.t:Species"/>
	    </operator>
	
	    <operator id='YuleBirthRateScaler.t:Species' spec='ScaleOperator' scaleFactor="0.75" weight="3" parameter="@birthRate.t:Species"/>

        <logger id='tracelog' logEvery="5000" fileName="beast.log" sort="smart">
	        <model idref='posterior'/>
            <log idref="posterior"/>
            <log idref="likelihood"/>
            <log idref="prior"/>
			<log idref="speciescoalescent"/>
			<log idref="birthRate.t:Species"/>
			<log idref="YuleModel.t:Species"/>
			<log idref="popMean"/>
            <log id='TreeHeight.Species' spec='beast.evolution.tree.TreeHeightLogger' tree='@Tree.t:Species'/>
        </logger>

		<logger fileName="species.trees" id="speciesTreeLogger" logEvery="5000" mode="tree">
		    <log id='SpeciesTreeLoggerX' spec='SpeciesTreeLogger' popSize='@popSize' popSizeTop="@popSizeTop" tree="@Tree.t:Species" speciesTreePrior='@SpeciesTreePopSize.Species' treetop='@treeTopFinder'/>
		</logger>

        <logger id='screenlog' logEvery="5000">
	        <model idref='posterior'/>
            <log idref="posterior"/>
      	    <ESS spec='ESS' name='log' arg="@posterior"/>
            <log idref="likelihood"/>
            <log idref="prior"/>
        </logger>


<!-- use with calibrated yule-->
        <init spec='beast.evolution.tree.RandomTree' id='RandomTree.t:Species' estimate='false' initial='@Tree.t:Species' taxonset='@taxonsuperset'>
            <populationModel id='ConstantPopulation0.Species' spec='ConstantPopulation'>
        		<popSize id='randomPopSize.Species' spec='parameter.RealParameter' value='1'/>
            </populationModel>
        </init>

<!-- use without calibrated yule-->
		<init id="SBI"  spec="beast.evolution.speciation.StarBeastStartState"
		  speciesTree="@Tree.t:Species"
		  speciesTreePrior="@SpeciesTreePopSize.Species"
		  popMean="@popMean"
		  birthRate="@birthRate.t:Species">
		  <!--baseRate idref="clockRate.sb_l0_example03"/-->
		</init>
    </run>

</beast>




