function GUIBuildCodonFrequencies (EFV)
{
	PIStop = 1.0;
	result = {ModelMatrixDimension,1};
	hshift = 0;

	for (h=0; h<64; h=h+1)
	{
		first  = h$16;
		second = h%16$4;
		third  = h%4;
		if (ModelGeneticCode[h]==10) 
		{
			hshift = hshift+1;
			PIStop = PIStop-EFV[first][0]*EFV[second][1]*EFV[third][2];
			continue; 
		}
		result[h-hshift][0]=EFV[first][0]*EFV[second][1]*EFV[third][2];
	}
	return result*(1.0/PIStop);
}

function GUIHandleFrequenciesCollection (dummy_parameter)
{
	HarvestFrequencies (Model_EFV_Vector,Data_Set_ID,3,1,1);
	MULTIPLY_BY_FREQS = 0;
	return 	0;
}

/** MATRIX MODIFICATION CODE **/

EFVModifierMatrix = {ModelMatrixDimension,ModelMatrixDimension}; 
hshift = 0;

for (h=0; h<64; h=h+1)
{
	if (ModelGeneticCode[h]==10) 
	{
		hshift = hshift+1;
		continue; 
	}
	vshift = hshift;
	for (v = h+1; v<64; v=v+1)
	{
		diff = v-h;
		if (ModelGeneticCode[v]==10) 
		{
			vshift = vshift+1;
			continue; 
		}
		modString2 = "[2]";
	  	if ((h$4==v$4)||((diff%4==0)&&(h$16==v$16))||(diff%16==0))
	  	{
	  		if (h$4==v$4)
	  		{
	  			transition = v%4;
	  			transition2= h%4;
	  		}
	  		else
	  		{
	  			if(diff%16==0)
	  			{
	  				transition = v$16;
	  				transition2= h$16;
					modString2 = "[0]";
	  			}
	  			else
	  			{
	  				transition = v%16$4;
	  				transition2= h%16$4;
					modString2 = "[1]";
	  			}
			}
	  		modString  = "EFV__[";
	  		if (transition==0) 
	  		{
	  			modString = "EFV__[0]";
		  	}
		  	else
		  	{
		  		if (transition==1) 
		  		{
		  			modString = "EFV__[1]";
			  	}		  	
			  	else
			  	{
			  		if (transition==2) 
			  		{
			  			modString = "EFV__[2]";
				  	}		  	
				  	else
			  		{
			  			modString = "EFV__[3]";
				  	}		  	
				  	
			  	}
		  	}
		  	
		  	modString = modString+modString2;
	  		EFVModifierMatrix[h-hshift][v-vshift] := modString__;
		  	
			if (transition2==0) 
	  		{
	  			modString = "EFV__[0]";
		  	}
		  	else
		  	{
		  		if (transition2==1) 
		  		{
		  			modString = "EFV__[1]";
			  	}		  	
			  	else
			  	{
			  		if (transition2==2) 
			  		{
			  			modString = "EFV__[2]";
				  	}		  	
				  	else
			  		{
			  			modString2 = "EFV__[3]";
				  	}		  	
				  	
			  	}
		  	}	  	
		  	modString = modString+modString2;
	  		EFVModifierMatrix[v-vshift][h-hshift] := modString__;
		 }
    }
}


