/* This file defines the transition matrix for the Kimura 2 parameter 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:K2P#
   	#Desc:Kimura 2 parameter (K2P). Local or global parameters. Possible Gamma Variation.#
   	#Dimension:4#
    #DataType:nucleotide#
   	#FileName:K2P.mdl#
   
   08/18/1999  by Sergei L. Kosakovsky Pond
*/

equalFreqs = {{.25}{.25}{.25}{.25}};

#include "modelParameters.mdl";

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

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

K2P = 0;

MULTIPLY_BY_FREQS = PopulateModelMatrix ("K2P",equalFreqs);

Model K2PModel = (K2P, equalFreqs, MULTIPLY_BY_FREQS);

FREQUENCY_SENSITIVE = 0;

DUPLICATE_MODELS_OK = 1;
