/* This file defines the transition matrix for the Kimura(1981) 3 substitution type model.
   The file should be used as follows:
   
   1) Read Data File and create datafilter filteredData
   2) #include this file (or use SelectTemplateModel(filteredData);)
   3) Define the tree
   4) Proceed with the likelihood function using 'vectorOfFrequencies' as the vector to pass to the constructor.
   
   This model has the following signature:
    #Short:K3ST#
   	#Desc:Kimura(1981) 3 substitution type model. Local or global parameters. Possible Gamma Variation.#
   	#Dimension:4#
    #DataType:nucleotide#
   	#FileName:K3ST.mdl#
   
   04/04/2000  by Sergei L. Kosakovsky Pond
*/

#include "modelParameters.mdl";

if (modelType >= 1)
{
	global R1 = 1.;
	global R2 = 1.;
	
	if (modelType == 2)
	{
		#include "defineGamma.mdl";
	}
	if (modelType == 3)
	{
		#include "defineHM.mdl";
	}
}

function PopulateModelMatrix (ModelMatrixName&, EFV)
{
	if (modelType == 0)
	{
		ModelMatrixName = {{*,a,b,c}{a,*,c,b}{b,c,*,a}{c,b,a,*}};
	}
	else
	{
		if (modelType<2)
		{
			ModelMatrixName = {{*,R1*b,b,R2*b}{R1*b,*,R2*b,b}{b,R2*b,*,R1*b}{R2*b,b,R1*b,*}};
		}
		else
		{
			ModelMatrixName = {{*,R1*b*c,b*c,R2*b*c}{R1*b*c,*,R2*b*c,b*c}{b*c,R2*b*c,*,R1*b*c}{R2*b*c,b*c,R1*b*c,*}};
		}
	}
	return 1;
}

K3ST = 0;

vectorOfFrequencies = {{.25}{.25}{.25}{.25}};

MULTIPLY_BY_FREQS = PopulateModelMatrix ("K3ST",vectorOfFrequencies);

Model K3STModel = (K3ST, vectorOfFrequencies, MULTIPLY_BY_FREQS);

FREQUENCY_SENSITIVE = 0;
