<beast version='2.0'
       namespace='beastfx.app.beauti:beast.pkgmgmt:beast.base.core:beast.base.inference:beast.base.evolution.branchratemodel:beast.base.evolution.speciation:beast.base.evolution.tree.coalescent:beast.base.util:beast.base.math:beast.evolution.nuc:beast.base.evolution.operator:beast.base.inference.operator:beast.base.evolution.sitemodel:beast.base.evolution.substitutionmodel:beast.base.evolution.likelihood:beast.evolution:beast.base.inference.distribution'>

       
       
       
    <mergewith point='substModelTemplates'>
    
        <!-- gamma site model -->
        <subtemplate id='Gamma Site Model' class='beast.base.evolution.sitemodel.SiteModel' mainid='SiteModel.s:$(n)'
            hmc='SiteModel/proportionInvariant/,
SiteModel/mutationRate/,
SiteModel/gammaCategoryCount/,
SiteModel/shape/,
SiteModel/substModel/,
gammaShapeScaler/index/=Operators/BactrianRateScaler/index/,
proportionInvariantScaler/index/=Operators/BactrianRateScaler/index/,
mutationRateScaler/index/=Operators/BactrianRateScaler/index/,
GammaShapePrior/index/=Priors/GammaShapePrior/,
PropInvariantPrior/index/=Priors/PropInvariantPrior/,
MutationRatePrior/index/=Priors/MutationRatePrior/
'>
            <![CDATA[
            <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' lower="0.0" estimate='false'/>
                <shape               spec='parameter.RealParameter' id='gammaShape.s:$(n)' value='1.0' lower="0.1" estimate='false'/>
            </plugin>

            <prior id='MutationRatePrior.s:$(n)' x='@mutationRate.s:$(n)'><distr spec="OneOnX"/></prior>
            <prior id='GammaShapePrior.s:$(n)' x='@gammaShape.s:$(n)'><distr spec="beast.base.inference.distribution.Exponential" mean='1'/></prior>
            <prior id='PropInvariantPrior.s:$(n)' x='@proportionInvariant.s:$(n)'><distr spec="beast.base.inference.distribution.Uniform" lower='0' upper='1'/></prior>

			<operator id="AVMNOperator.$(n)" spec="beast.base.evolution.operator.kernel.AdaptableVarianceMultivariateNormalOperator" weight="0.1" 
                coefficient="1.0"
                scaleFactor="1"
                beta="0.05"
                initial="800"
                burnin="400"
                every="1" allowNonsense="true">
            	<transformations id="AVMNSumTransform.$(n)" spec="beast.base.inference.operator.kernel.Transform$LogConstrainedSumTransform" sum="1.0">
            		<!-- frequencies -->
            	</transformations>
            	<transformations id="AVMNLogTransform.$(n)" spec="beast.base.inference.operator.kernel.Transform$LogTransform">
             		<!-- site and substitution model parameters -->
            	</transformations>
            	<transformations id="AVMNNoTransform.$(n)" spec="beast.base.inference.operator.kernel.Transform$NoTransform">
             		<!-- tree -->
            	</transformations>
            </operator>

        	<operator id="proportionInvariantScaler.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
                <parameter idref="proportionInvariant.s:$(n)"/>
            	<operator idref="AVMNOperator.$(n)"/>
            	<operator id='proportionInvariantScalerX.s:$(n)' spec='kernel.BactrianScaleOperator' scaleFactor="0.5" weight="0.1" parameter="@proportionInvariant.s:$(n)"/>
        	</operator>

        	<operator id="mutationRateScaler.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
                <parameter idref="mutationRate.s:$(n)"/>
            	<operator idref="AVMNOperator.$(n)"/>
	            <operator id='mutationRateScalerX.s:$(n)' spec='kernel.BactrianScaleOperator' scaleFactor="0.5" weight="0.1" parameter="@mutationRate.s:$(n)"/>
        	</operator>

        	<operator id="gammaShapeScaler.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
                <parameter idref="gammaShape.s:$(n)"/>
            	<operator idref="AVMNOperator.$(n)"/>
	            <operator id='gammaShapeScalerX.s:$(n)' spec='kernel.BactrianScaleOperator' scaleFactor="0.5" weight="0.1" parameter="@gammaShape.s:$(n)"/>
        	</operator>
            ]]>

                        <connect method="beastfx.app.inputeditor.SiteModelInputEditor.customConnector"/>

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

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


            <connect srcID='proportionInvariantScaler.s:$(n)' targetID='mcmc' inputName='operator' if='inlikelihood(proportionInvariant.s:$(n)) and proportionInvariant.s:$(n)/estimate=true'>Scales proportion of invariant sites parameter of partition $(n)</connect>
            <connect srcID='mutationRateScaler.s:$(n)'        targetID='mcmc' inputName='operator' if='nooperator(FixMeanMutationRatesOperator) and inlikelihood(mutationRate.s:$(n)) and mutationRate.s:$(n)/estimate=true'>Scales mutation rate of partition s:$(n)</connect>
            <connect srcID='gammaShapeScaler.s:$(n)'          targetID='mcmc' inputName='operator' if='inlikelihood(gammaShape.s:$(n)) and gammaShape.s:$(n)/estimate=true'>Scales gamma shape parameter of partition s:$(n)</connect>

            <connect srcID='proportionInvariant.s:$(n)'       targetID='tracelog' inputName='log' if='inposterior(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='GammaShapePrior.s:$(n)'           targetID='prior' inputName='distribution' if='inlikelihood(gammaShape.s:$(n)) and gammaShape.s:$(n)/estimate=true'>Prior on gamma shape for partition s:$(n)</connect>
            <connect srcID='PropInvariantPrior.s:$(n)'        targetID='prior' inputName='distribution' if='inlikelihood(proportionInvariant.s:$(n)) and proportionInvariant.s:$(n)/estimate=true'>Prior on proportion invariant for partition s:$(n)</connect>

        </subtemplate>

    

        <!-- substitution models -->
        <!-- JC69 substitution model -->
        <subtemplate id='JC69' class='beast.base.evolution.substitutionmodel.JukesCantor' mainid='JC69.s:$(n)'>
            <![CDATA[
        <plugin spec='JukesCantor' id='JC69.s:$(n)'/>
]]>
        </subtemplate>

        <!-- HKY substitution model -->
        <subtemplate id='HKY' class='beast.base.evolution.substitutionmodel.HKY' mainid='hky.s:$(n)'
            hmc='hky/frequencies/,hky/kappa/,KappaPrior/index/=Priors/KappaPrior/,
            KappaScaler/index/=Operators/BactrianRateScaler/index/'>
            <![CDATA[
        <plugin spec='HKY' id='hky.s:$(n)'>
            <parameter id="kappa.s:$(n)" name='kappa' value="2.0" lower="0.0" estimate='true'/>
            <frequencies id='estimatedFreqs.s:$(n)' spec='Frequencies'>
                <frequencies id='freqParameter.s:$(n)' spec='parameter.RealParameter' dimension='4' value='0.25' lower='0' upper='1'/>
            </frequencies>
        </plugin>

        <operator id="KappaScaler.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
            <parameter idref="kappa.s:$(n)"/>
        	<operator idref="AVMNOperator.$(n)"/>
		    <operator id='KappaScalerX.s:$(n)' spec='kernel.BactrianScaleOperator' scaleFactor="0.1" weight="0.1" parameter="@kappa.s:$(n)"/>
        </operator>

        <operator id="FrequenciesExchanger.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
            <parameter idref="freqParameter.s:$(n)"/>
        	<operator idref="AVMNOperator.$(n)"/>
	        <operator id='FrequenciesExchangerX.s:$(n)' spec='kernel.BactrianDeltaExchangeOperator' delta="0.01" weight="0.1" parameter="@freqParameter.s:$(n)"/>
        </operator>

        <prior id='KappaPrior.s:$(n)' x='@kappa.s:$(n)'>
            <distr spec="LogNormalDistributionModel" meanInRealSpace='false'>
                <parameter name='M' value="1.0" estimate='false'/>
                <parameter name='S' value="1.25" estimate='false'/>
            </distr>
		</prior>
        <prior id='FrequenciesPrior.s:$(n)' x='@freqParameter.s:$(n)'>
			<distr spec="beast.base.inference.distribution.Dirichlet">
                <parameter spec="parameter.RealParameter" dimension="4" estimate="false" name="alpha">4.0 4.0 4.0 4.0</parameter>
            </distr> 
        </prior>

]]>

            <connect srcID='kappa.s:$(n)' targetID='state' inputName='stateNode'
                     if='inlikelihood(kappa.s:$(n)) and kappa.s:$(n)/estimate=true'/>
            <connect srcID='freqParameter.s:$(n)' targetID='state' inputName='stateNode'
                     if='inlikelihood(hky.$(n)) and inlikelihood(freqParameter.s:$(n)) and freqParameter.s:$(n)/estimate=true'/>

            <connect srcID='kappa.s:$(n)' targetID='AVMNLogTransform.$(n)' inputName='f'
                     if='inlikelihood(kappa.s:$(n)) and kappa.s:$(n)/estimate=true'/>

            <connect srcID='KappaScaler.s:$(n)' targetID='mcmc' inputName='operator'
                     if='inlikelihood(kappa.s:$(n)) and kappa.s:$(n)/estimate=true'>Scale HKY transition-transversion
                parameter of partition s:$(n)
            </connect>
            <connect srcID='FrequenciesExchanger.s:$(n)' targetID='mcmc' inputName='operator'
                     if='inlikelihood(hky.$(n)) and inlikelihood(freqParameter.s:$(n)) and freqParameter.s:$(n)/estimate=true'>
                Exchange values of frequencies of partition s:$(n)
            </connect>

            <connect srcID='kappa.s:$(n)' targetID='tracelog' inputName='log'
                     if='inlikelihood(kappa.s:$(n)) and kappa.s:$(n)/estimate=true'/>
            <connect srcID='freqParameter.s:$(n)' targetID='tracelog' inputName='log'
                     if='inlikelihood(hky.$(n)) and inlikelihood(freqParameter.s:$(n)) and freqParameter.s:$(n)/estimate=true'/>

            <connect srcID='KappaPrior.s:$(n)' targetID='prior' inputName='distribution'
                     if='inlikelihood(kappa.s:$(n)) and kappa.s:$(n)/estimate=true'>HKY transition-transversion
                parameter of partition s:$(n)
            </connect>
        </subtemplate>


        <!-- TN93 substitution model -->
        <subtemplate id='TN93' class='beast.base.evolution.substitutionmodel.TN93' mainid='tn93.s:$(n)'
            hmc='tn93/kappa1/,tn93/frequencies/,tn93/kappa2/,kappa1Prior/index/,kappa2Prior/index/,
            kappa1Scaler/index/=Operators/BactrianRateScaler/index/,
            kappa2Scaler/index/=Operators/BactrianRateScaler/index/'>
            <![CDATA[
        <plugin spec='TN93' id='tn93.s:$(n)'>
            <parameter id="kappa1.s:$(n)" name='kappa1' value="2.0" lower="0.0" estimate='true'/>
            <parameter id="kappa2.s:$(n)" name='kappa2' value="2.0" lower="0.0" estimate='true'/>
            <frequencies id='estimatedFreqs.s:$(n)' spec='Frequencies'>
                <frequencies id='freqParameter.s:$(n)' spec='parameter.RealParameter' dimension='4' value='0.25' lower='0' upper='1'/>
            </frequencies>
        </plugin>

        <operator id="kappa1Scaler.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
            <parameter idref="kappa1.s:$(n)"/>
        	<operator idref="AVMNOperator.$(n)"/>
	        <operator id='kappa1ScalerX.s:$(n)' spec='kernel.BactrianScaleOperator' scaleFactor="0.5" weight="0.1" parameter="@kappa1.s:$(n)"/>
        </operator>

        <operator id="kappa2Scaler.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
            <parameter idref="kappa2.s:$(n)"/>
        	<operator idref="AVMNOperator.$(n)"/>
	        <operator id='kappa2ScalerX.s:$(n)' spec='kernel.BactrianScaleOperator' scaleFactor="0.5" weight="0.1" parameter="@kappa2.s:$(n)"/>
        </operator>

        <operator id="FrequenciesExchanger.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
            <parameter idref="freqParameter.s:$(n)"/>
        	<operator idref="AVMNOperator.$(n)"/>
	        <operator id='FrequenciesExchangerX.s:$(n)' spec='kernel.BactrianDeltaExchangeOperator' delta="0.01" weight="0.1" parameter="@freqParameter.s:$(n)"/>
        </operator>

        <prior id='kappa1Prior.s:$(n)' x='@kappa1.s:$(n)'>
            <distr spec="LogNormalDistributionModel" meanInRealSpace='false'>
                <parameter name='M' value="1.0" estimate='false'/>
                <parameter name='S' value="1.25" estimate='false'/>
            </distr>
	</prior>
        <prior id='kappa2Prior.s:$(n)' x='@kappa2.s:$(n)'>
            <distr spec="LogNormalDistributionModel" meanInRealSpace='false'>
                <parameter name='M' value="1.0" estimate='false'/>
                <parameter name='S' value="1.25" estimate='false'/>
            </distr>
	</prior>
    <prior id='FrequenciesPrior.s:$(n)' x='@freqParameter.s:$(n)'>
			<distr spec="beast.base.inference.distribution.Dirichlet">
                <parameter spec="parameter.RealParameter" dimension="4" estimate="false" name="alpha">4.0 4.0 4.0 4.0</parameter>
            </distr> 
	</prior>

]]>

            <connect srcID='kappa1.s:$(n)' targetID='state' inputName='stateNode'
                     if='inlikelihood(kappa1.s:$(n)) and kappa1.s:$(n)/estimate=true'/>
            <connect srcID='kappa2.s:$(n)' targetID='state' inputName='stateNode'
                     if='inlikelihood(kappa2.s:$(n)) and kappa2.s:$(n)/estimate=true'/>

            <connect srcID='kappa1.s:$(n)' targetID='AVMNLogTransform.$(n)' inputName='f'
                     if='inlikelihood(kappa1.s:$(n)) and kappa1.s:$(n)/estimate=true'/>
            <connect srcID='kappa2.s:$(n)' targetID='AVMNLogTransform.$(n)' inputName='f'
                     if='inlikelihood(kappa2.s:$(n)) and kappa2.s:$(n)/estimate=true'/>

            <connect srcID='kappa1Scaler.s:$(n)' targetID='mcmc' inputName='operator'
                     if='inlikelihood(kappa1.s:$(n)) and kappa1.s:$(n)/estimate=true'>Scale TN93 kappa1 (rateAG)
                parameter of partition s:$(n)
            </connect>
            <connect srcID='kappa2Scaler.s:$(n)' targetID='mcmc' inputName='operator'
                     if='inlikelihood(kappa2.s:$(n)) and kappa2.s:$(n)/estimate=true'>Scale TN93 kappa2 (rateCT)
                parameter of partition s:$(n)
            </connect>
            <connect srcID='FrequenciesExchanger.s:$(n)' targetID='mcmc' inputName='operator'
                     if='inlikelihood(hky.$(n)) and inlikelihood(freqParameter.s:$(n)) and freqParameter.s:$(n)/estimate=true'>
                Exchange values of frequencies of partition s:$(n)
            </connect>

            <connect srcID='kappa1.s:$(n)' targetID='tracelog' inputName='log'
                     if='inlikelihood(kappa1.s:$(n)) and kappa1.s:$(n)/estimate=true'/>
            <connect srcID='kappa2.s:$(n)' targetID='tracelog' inputName='log'
                     if='inlikelihood(kappa2.s:$(n)) and kappa2.s:$(n)/estimate=true'/>
            <connect srcID='freqParameter.s:$(n)' targetID='tracelog' inputName='log'
                     if='inlikelihood(hky.$(n)) and inlikelihood(freqParameter.s:$(n)) and freqParameter.s:$(n)/estimate=true'/>

            <connect srcID='kappa1Prior.s:$(n)' targetID='prior' inputName='distribution'
                     if='inlikelihood(kappa1.s:$(n)) and kappa1.s:$(n)/estimate=true'>TN93 kappa1 (rateAG) parameter of
                partition s:$(n)
            </connect>
            <connect srcID='kappa2Prior.s:$(n)' targetID='prior' inputName='distribution'
                     if='inlikelihood(kappa2.s:$(n)) and kappa2.s:$(n)/estimate=true'>TN93 kappa2 (rateCT) parameter of
                partition s:$(n)
            </connect>
        </subtemplate>


        <!-- GTR substitution model -->
        <subtemplate id='GTR' class='beast.base.evolution.substitutionmodel.GTR' mainid='gtr.s:$(n)'
                     suppressInputs='beast.base.evolution.substitutionmodel.GTR.eigenSystem'
                     hmc='gtr/rateGT/,
gtr/frequencies/,
gtr/rateAT/,
gtr/rateAC/,
gtr/rateCG/,
gtr/rateAG/,
gtr/rateCT/,
RateACPrior/index/=Priors/RateGTRPrior/,
RateAGPrior/index/=Priors/RateGTRPrior/,
RateATPrior/index/=Priors/RateGTRPrior/,
RateCGPrior/index/=Priors/RateGTRPrior/,
RateCTPrior/index/=Priors/RateGTRPrior/,
RateGTPrior/index/=Priors/RateGTRPrior/,
            RateACScaler/index/=Operators/BactrianRateScaler/index/,
            RateAGScaler/index/=Operators/BactrianRateScaler/index/,
            RateATScaler/index/=Operators/BactrianRateScaler/index/,
            RateCGScaler/index/=Operators/BactrianRateScaler/index/,
            RateCTScaler/index/=Operators/BactrianRateScaler/index/,
            RateGTScaler/index/=Operators/BactrianRateScaler/index/'>
            <![CDATA[
        <plugin spec='GTR' id='gtr.s:$(n)'>
            <parameter id="rateAC.s:$(n)" name='rateAC' value="1.0" lower="0.0" estimate='true'/>
            <parameter id="rateAG.s:$(n)" name='rateAG' value="1.0" lower="0.0" estimate='true'/>
            <parameter id="rateAT.s:$(n)" name='rateAT' value="1.0" lower="0.0" estimate='true'/>
            <parameter id="rateCG.s:$(n)" name='rateCG' value="1.0" lower="0.0" estimate='true'/>
            <parameter id="rateCT.s:$(n)" name='rateCT' value="1.0" lower="0.0" estimate='false'/>
            <parameter id="rateGT.s:$(n)" name='rateGT' value="1.0" lower="0.0" estimate='true'/>
            <frequencies id='estimatedFreqs.s:$(n)' spec='Frequencies'>
                <frequencies id='freqParameter.s:$(n)' spec='parameter.RealParameter' dimension='4' value='0.25' lower='0' upper='1'/>
            </frequencies>
        </plugin>

        <operator id="RateACScaler.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
            <parameter idref="rateAC.s:$(n)"/>
        	<operator idref="AVMNOperator.$(n)"/>
	        <operator id='RateACScalerX.s:$(n)' spec='kernel.BactrianScaleOperator' scaleFactor="0.5" weight="0.1" parameter="@rateAC.s:$(n)"/>
        </operator>

        <operator id="RateAGScaler.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
            <parameter idref="rateAG.s:$(n)"/>
        	<operator idref="AVMNOperator.$(n)"/>
	        <operator id='RateAGScalerX.s:$(n)' spec='kernel.BactrianScaleOperator' scaleFactor="0.5" weight="0.1" parameter="@rateAG.s:$(n)"/>
        </operator>

        <operator id="RateATScaler.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
            <parameter idref="rateAT.s:$(n)"/>
        	<operator idref="AVMNOperator.$(n)"/>
	        <operator id='RateATScalerX.s:$(n)' spec='kernel.BactrianScaleOperator' scaleFactor="0.5" weight="0.1" parameter="@rateAT.s:$(n)"/>
        </operator>

        <operator id="RateCGScaler.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
            <parameter idref="rateCG.s:$(n)"/>
        	<operator idref="AVMNOperator.$(n)"/>
	        <operator id='RateCGScalerX.s:$(n)' spec='kernel.BactrianScaleOperator' scaleFactor="0.5" weight="0.1" parameter="@rateCG.s:$(n)"/>
        </operator>

        <operator id="RateCTScaler.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
            <parameter idref="rateCT.s:$(n)"/>
        	<operator idref="AVMNOperator.$(n)"/>
	        <operator id='RateCTScalerX.s:$(n)' spec='kernel.BactrianScaleOperator' scaleFactor="0.5" weight="0.1" parameter="@rateCT.s:$(n)"/>
        </operator>

        <operator id="RateGTScaler.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
            <parameter idref="rateGT.s:$(n)"/>
        	<operator idref="AVMNOperator.$(n)"/>
	        <operator id='RateGTScalerX.s:$(n)' spec='kernel.BactrianScaleOperator' scaleFactor="0.5" weight="0.1" parameter="@rateGT.s:$(n)"/>
        </operator>

        <operator id="FrequenciesExchanger.s:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
            <parameter idref="freqParameter.s:$(n)"/>
        	<operator idref="AVMNOperator.$(n)"/>
	        <operator id='FrequenciesExchangerX.s:$(n)' spec='kernel.BactrianDeltaExchangeOperator' delta="0.01" weight="0.1" parameter="@freqParameter.s:$(n)"/>
        </operator>

        <prior id='RateACPrior.s:$(n)' x='@rateAC.s:$(n)'><distr spec="beast.base.inference.distribution.Gamma"><parameter name="alpha" value='0.05' estimate='false'/><parameter name="beta" value='10.0' estimate='false'/></distr></prior>
        <prior id='RateAGPrior.s:$(n)' x='@rateAG.s:$(n)'><distr spec="beast.base.inference.distribution.Gamma"><parameter name="alpha" value='0.05' estimate="false"/><parameter name="beta" value='20.0' estimate="false"/></distr></prior>
        <prior id='RateATPrior.s:$(n)' x='@rateAT.s:$(n)'><distr spec="beast.base.inference.distribution.Gamma"><parameter name="alpha" value='0.05' estimate="false"/><parameter name="beta" value='10.0' estimate="false"/></distr></prior>
        <prior id='RateCGPrior.s:$(n)' x='@rateCG.s:$(n)'><distr spec="beast.base.inference.distribution.Gamma"><parameter name="alpha" value='0.05' estimate="false"/><parameter name="beta" value='10.0' estimate="false"/></distr></prior>
        <prior id='RateCTPrior.s:$(n)' x='@rateCT.s:$(n)'><distr spec="beast.base.inference.distribution.Gamma"><parameter name="alpha" value='0.05' estimate="false"/><parameter name="beta" value='20.0' estimate="false"/></distr></prior>
        <prior id='RateGTPrior.s:$(n)' x='@rateGT.s:$(n)'><distr spec="beast.base.inference.distribution.Gamma"><parameter name="alpha" value='0.05' estimate="false"/><parameter name="beta" value='10.0' estimate="false"/></distr></prior>

        <prior id='FrequenciesPrior.s:$(n)' x='@freqParameter.s:$(n)'>
			<distr spec="beast.base.inference.distribution.Dirichlet">
                <parameter spec="parameter.RealParameter" dimension="4" estimate="false" name="alpha">4.0 4.0 4.0 4.0</parameter>
            </distr> 
		</prior>
]]>

            <connect srcID='freqParameter.s:$(n)' targetID='state' inputName='stateNode'
                     if='inlikelihood(freqParameter.s:$(n)) and freqParameter.s:$(n)/estimate=true'/>
            <connect srcID='rateAC.s:$(n)' targetID='state' inputName='stateNode'
                     if='inlikelihood(rateAC.s:$(n)) and rateAC.s:$(n)/estimate=true'/>
            <connect srcID='rateAG.s:$(n)' targetID='state' inputName='stateNode'
                     if='inlikelihood(rateAG.s:$(n)) and rateAG.s:$(n)/estimate=true'/>
            <connect srcID='rateAT.s:$(n)' targetID='state' inputName='stateNode'
                     if='inlikelihood(rateAT.s:$(n)) and rateAT.s:$(n)/estimate=true'/>
            <connect srcID='rateCG.s:$(n)' targetID='state' inputName='stateNode'
                     if='inlikelihood(rateCG.s:$(n)) and rateCG.s:$(n)/estimate=true'/>
            <connect srcID='rateCT.s:$(n)' targetID='state' inputName='stateNode'
                     if='inlikelihood(rateCT.s:$(n)) and rateCT.s:$(n)/estimate=true'/>
            <connect srcID='rateGT.s:$(n)' targetID='state' inputName='stateNode'
                     if='inlikelihood(rateGT.s:$(n)) and rateGT.s:$(n)/estimate=true'/>

            <connect srcID='rateAC.s:$(n)' targetID='AVMNLogTransform.$(n)' inputName='f'
                     if='inlikelihood(rateAC.s:$(n)) and rateAC.s:$(n)/estimate=true'/>
            <connect srcID='rateAG.s:$(n)' targetID='AVMNLogTransform.$(n)' inputName='f'
                     if='inlikelihood(rateAG.s:$(n)) and rateAG.s:$(n)/estimate=true'/>
            <connect srcID='rateAT.s:$(n)' targetID='AVMNLogTransform.$(n)' inputName='f'
                     if='inlikelihood(rateAT.s:$(n)) and rateAT.s:$(n)/estimate=true'/>
            <connect srcID='rateCG.s:$(n)' targetID='AVMNLogTransform.$(n)' inputName='f'
                     if='inlikelihood(rateCG.s:$(n)) and rateCG.s:$(n)/estimate=true'/>
            <connect srcID='rateCT.s:$(n)' targetID='AVMNLogTransform.$(n)' inputName='f'
                     if='inlikelihood(rateCT.s:$(n)) and rateCT.s:$(n)/estimate=true'/>
            <connect srcID='rateGT.s:$(n)' targetID='AVMNLogTransform.$(n)' inputName='f'
                     if='inlikelihood(rateGT.s:$(n)) and rateGT.s:$(n)/estimate=true'/>


            <connect srcID='FrequenciesExchanger.s:$(n)' targetID='mcmc' inputName='operator'
                     if='inlikelihood(freqParameter.s:$(n)) and freqParameter.s:$(n)/estimate=true'>Exchange values of
                frequencies of partition s:$(n)
            </connect>
            <connect srcID='RateACScaler.s:$(n)' targetID='mcmc' inputName='operator'
                     if='inlikelihood(rateAC.s:$(n)) and rateAC.s:$(n)/estimate=true'>Scale GTR A-C substitution
                parameter of partition s:$(n)
            </connect>
            <connect srcID='RateAGScaler.s:$(n)' targetID='mcmc' inputName='operator'
                     if='inlikelihood(rateAG.s:$(n)) and rateAG.s:$(n)/estimate=true'>Scale GTR A-G substitution
                parameter of partition s:$(n)
            </connect>
            <connect srcID='RateATScaler.s:$(n)' targetID='mcmc' inputName='operator'
                     if='inlikelihood(rateAT.s:$(n)) and rateAT.s:$(n)/estimate=true'>Scale GTR A-T substitution
                parameter of partition s:$(n)
            </connect>
            <connect srcID='RateCGScaler.s:$(n)' targetID='mcmc' inputName='operator'
                     if='inlikelihood(rateCG.s:$(n)) and rateCG.s:$(n)/estimate=true'>Scale GTR C-G substitution
                parameter of partition s:$(n)
            </connect>
            <connect srcID='RateCTScaler.s:$(n)' targetID='mcmc' inputName='operator'
                     if='inlikelihood(rateCT.s:$(n)) and rateCT.s:$(n)/estimate=true'>Scale GTR C-T substitution
                parameter of partition s:$(n)
            </connect>
            <connect srcID='RateGTScaler.s:$(n)' targetID='mcmc' inputName='operator'
                     if='inlikelihood(rateGT.s:$(n)) and rateGT.s:$(n)/estimate=true'>Scale GTR G-T substitution
                parameter of partition s:$(n)
            </connect>

            <connect srcID='freqParameter.s:$(n)' targetID='tracelog' inputName='log'
                     if='inlikelihood(freqParameter.s:$(n)) and freqParameter.s:$(n)/estimate=true'/>
            <connect srcID='rateAC.s:$(n)' targetID='tracelog' inputName='log'
                     if='inlikelihood(rateAC.s:$(n)) and rateAC.s:$(n)/estimate=true'/>
            <connect srcID='rateAG.s:$(n)' targetID='tracelog' inputName='log'
                     if='inlikelihood(rateAG.s:$(n)) and rateAG.s:$(n)/estimate=true'/>
            <connect srcID='rateAT.s:$(n)' targetID='tracelog' inputName='log'
                     if='inlikelihood(rateAT.s:$(n)) and rateAT.s:$(n)/estimate=true'/>
            <connect srcID='rateCG.s:$(n)' targetID='tracelog' inputName='log'
                     if='inlikelihood(rateCG.s:$(n)) and rateCG.s:$(n)/estimate=true'/>
            <connect srcID='rateCT.s:$(n)' targetID='tracelog' inputName='log'
                     if='inlikelihood(rateCT.s:$(n)) and rateCT.s:$(n)/estimate=true'/>
            <connect srcID='rateGT.s:$(n)' targetID='tracelog' inputName='log'
                     if='inlikelihood(rateGT.s:$(n)) and rateGT.s:$(n)/estimate=true'/>

            <connect srcID='RateACPrior.s:$(n)' targetID='prior' inputName='distribution'
                     if='inlikelihood(rateAC.s:$(n)) and rateAC.s:$(n)/estimate=true'>GTR A-C substitution parameter of
                partition s:$(n)
            </connect>
            <connect srcID='RateAGPrior.s:$(n)' targetID='prior' inputName='distribution'
                     if='inlikelihood(rateAG.s:$(n)) and rateAG.s:$(n)/estimate=true'>GTR A-G substitution parameter of
                partition s:$(n)
            </connect>
            <connect srcID='RateATPrior.s:$(n)' targetID='prior' inputName='distribution'
                     if='inlikelihood(rateAT.s:$(n)) and rateAT.s:$(n)/estimate=true'>GTR A-T substitution parameter of
                partition s:$(n)
            </connect>
            <connect srcID='RateCGPrior.s:$(n)' targetID='prior' inputName='distribution'
                     if='inlikelihood(rateCG.s:$(n)) and rateCG.s:$(n)/estimate=true'>GTR C-G substitution parameter of
                partition s:$(n)
            </connect>
            <connect srcID='RateCTPrior.s:$(n)' targetID='prior' inputName='distribution'
                     if='inlikelihood(rateCT.s:$(n)) and rateCT.s:$(n)/estimate=true'>GTR C-T substitution parameter of
                partition s:$(n)
            </connect>
            <connect srcID='RateGTPrior.s:$(n)' targetID='prior' inputName='distribution'
                     if='inlikelihood(rateGT.s:$(n)) and rateGT.s:$(n)/estimate=true'>GTR G-T substitution parameter of
                partition s:$(n)
            </connect>
        </subtemplate>


        <!-- empirical amino acid substitution models -->
        <subtemplate id='Blosum62' class='beast.base.evolution.substitutionmodel.Blosum62'
                     suppressInputs='beast.base.evolution.substitutionmodel.Blosum62.eigenSystem'
                     mainid='Blosum62.s:$(n)'><!--value spec='XML'-->
            <![CDATA[<plugin spec='Blosum62' id='Blosum62.s:$(n)'/>]]></subtemplate>
        <subtemplate id='Dayhoff' class='beast.base.evolution.substitutionmodel.Dayhoff'
                     suppressInputs='beast.base.evolution.substitutionmodel.Dayhoff.eigenSystem'
                     mainid='Dayhoff.s:$(n)'><!--value spec='XML'-->
            <![CDATA[<plugin spec='Dayhoff' id='Dayhoff.s:$(n)'/>]]></subtemplate>
        <subtemplate id='JTT' class='beast.base.evolution.substitutionmodel.JTT'
                     suppressInputs='beast.base.evolution.substitutionmodel.JTT.eigenSystem'
                     mainid='JTT.s:$(n)'><!--value spec='XML'-->
            <![CDATA[<plugin spec='JTT' id='JTT.s:$(n)'/>]]></subtemplate>
        <subtemplate id='cpREV' class='beast.base.evolution.substitutionmodel.CPREV'
                     suppressInputs='beast.base.evolution.substitutionmodel.CPREV.eigenSystem'
                     mainid='CPREV.s:$(n)'><!--value spec='XML'-->
            <![CDATA[<plugin spec='CPREV' id='CPREV.s:$(n)'/>]]></subtemplate>
        <subtemplate id='mtREV' class='beast.base.evolution.substitutionmodel.MTREV'
                     suppressInputs='beast.base.evolution.substitutionmodel.MTREV.eigenSystem'
                     mainid='MTREV.s:$(n)'><!--value spec='XML'-->
            <![CDATA[<plugin spec='MTREV' id='MTREV.s:$(n)'/>]]></subtemplate>
        <subtemplate id='WAG' class='beast.base.evolution.substitutionmodel.WAG'
                     suppressInputs='beast.base.evolution.substitutionmodel.WAG.eigenSystem'
                     mainid='WAG.s:$(n)'><!--value spec='XML'-->
            <![CDATA[<plugin spec='WAG' id='WAG.s:$(n)'/>]]></subtemplate>

        <!-- binary model -->
        <subtemplate id='MutationDeathModel' class='beast.base.evolution.substitutionmodel.MutationDeathModel'
                     mainid='MutationDeathModel.s:$(n)'
                     suppressInputs="beast.base.evolution.substitutionmodel.MutationDeathModel.substmodel,beast.base.evolution.substitutionmodel.MutationDeathModel.frequencies">
            <![CDATA[
		<plugin id='MutationDeathModel.s:$(n)' spec='beast.base.evolution.substitutionmodel.MutationDeathModel'>
			<parameter name='deathprob' id='deathprob.s:$(n)' value='0.1' lower="0.0" estimate='false'/>
			<frequencies id='freqs.s:$(n)' spec='Frequencies'>
				<frequencies spec='parameter.RealParameter' lower="0.0" value='1 0'/>
			</frequencies>
		</plugin>
]]>
        </subtemplate>


        <!-- frequency models -->
        <subtemplate id='Estimated' class='beast.base.evolution.substitutionmodel.Frequencies'
                     mainid='estimatedFreqs.s:$(n)' hmc='FrequenciesPrior/index/=Priors/FrequenciesPrior/,
                     FrequenciesExchanger/index/=Operators/BactrianDeltaExchange/index/'>
            <![CDATA[
            <frequencies id='estimatedFreqs.s:$(n)' spec='Frequencies'>
                <frequencies id='freqParameter.s:$(n)' spec='parameter.RealParameter' dimension='4' value='0.25' lower='0' upper='1'/>
            </frequencies>

	        <operator id="FrequenciesExchanger.c:$(n)" spec="beast.base.evolution.operator.AdaptableOperatorSampler" weight="0.05">
                <parameter idref="freqParameter.s:$(n)"/>
    	        <operator idref="AVMNOperator.$(n)"/>
		        <operator id='FrequenciesExchangerX.s:$(n)' spec='kernel.BactrianDeltaExchangeOperator' delta="0.01" weight="0.1" parameter="@freqParameter.s:$(n)"/>
	        </operator>

 ]]>
            <connect srcID='freqParameter.s:$(n)' targetID='state' inputName='stateNode'
                     if='inposterior(estimatedFreqs.s:$(n)) and inposterior(freqParameter.s:$(n)) and freqParameter.s:$(n)/estimate=true'/>
            <connect srcID='freqParameter.s:$(n)' targetID='AVMNSumTransform.$(n)' inputName='f'
                     if='inposterior(estimatedFreqs.s:$(n)) and inposterior(freqParameter.s:$(n)) and freqParameter.s:$(n)/estimate=true'/>

            <connect srcID='FrequenciesExchanger.s:$(n)' targetID='mcmc' inputName='operator'
                     if='inposterior(estimatedFreqs.s:$(n)) and inposterior(freqParameter.s:$(n)) and freqParameter.s:$(n)/estimate=true'>
                Exchange values of frequencies of partition s:$(n)
            </connect>
            <connect srcID='freqParameter.s:$(n)' targetID='tracelog' inputName='log'
                     if='inposterior(estimatedFreqs.s:$(n)) and inposterior(freqParameter.s:$(n)) and freqParameter.s:$(n)/estimate=true'/>
            <connect srcID='FrequenciesPrior.s:$(n)' targetID='prior' inputName='distribution'
                     if='inposterior(estimatedFreqs.s:$(n)) and inposterior(freqParameter.s:$(n)) and freqParameter.s:$(n)/estimate=true'/>
        </subtemplate>

        <subtemplate id='Empirical' class='beast.base.evolution.substitutionmodel.Frequencies'
                     mainid='empiricalFreqs.s:$(n)'>
            <![CDATA[
            <frequencies id='empiricalFreqs.s:$(n)' spec='Frequencies' data='@$(n)' estimate='true'/>
]]>
        </subtemplate>

        <subtemplate id='AllEqual' class='beast.base.evolution.substitutionmodel.Frequencies' mainid='equalFreqs.s:$(n)'>
            <![CDATA[
            <frequencies id='equalFreqs.s:$(n)' spec='Frequencies' data='@$(n)' estimate='false'/>
]]>
        </subtemplate>
    </mergewith>
    
    
</beast>

