function InitializeDistances (dummy)
{
	if (DISTANCE_PROMPTS)
	{

		ChoiceList (distChoice, "Distance computation",1,SKIP_NONE,
					"Synonymous p-distance","Number of synonymous substitutions divided by sequence length",
					"Non-synonymous p-distance","Number of non-synonymous substitutions divided by sequence length",
					"Joint p-distance","Total number of substitutions divided by sequence length");
					
					
		if (distChoice<0)
		{
			distChoice = 0;
		}	
		
		#include "CodonTools.def";

		matrixTrick  = {1,stateCharCount};
		matrixTrick2 = {1,stateCharCount};

		for (h=Columns(matrixTrick)-1; h>=0; h=h-1)
		{
			matrixTrick  [h] = h;
			matrixTrick2 [h] = 1;
		}
	}
	return 0;
}

/*----------------------------------------------------------------------------*/

function ComputeDistanceFormula (s1,s2)
{	
	_SITE_ON_COUNT = {stateCharCount,stateCharCount};
	
	GetDataInfo (siteDifferenceCount, filteredData, s1, s2, RESOLVE_AMBIGUITIES);
		
	
	if (distChoice == 0)
	{
		_SITE_OS_COUNT = {stateCharCount,stateCharCount};
		_SITE_OS_COUNT = matrixTrick2*(_OBSERVED_S_$siteDifferenceCount)*Transpose(matrixTrick2);
		return (_SITE_OS_COUNT[0]/filteredData.sites);
	}
	if (distChoice == 1)
	{
		_SITE_ON_COUNT = {stateCharCount,stateCharCount};
		_SITE_ON_COUNT = matrixTrick2*(_OBSERVED_NS_$siteDifferenceCount)*Transpose(matrixTrick2);
		return (_SITE_ON_COUNT[0]/filteredData.sites);
	}
	if (distChoice == 2)
	{
		_SITE_OS_COUNT = {stateCharCount,stateCharCount};
		_SITE_OS_COUNT = matrixTrick2*(_OBSERVED_S_$siteDifferenceCount)*Transpose(matrixTrick2);
		_SITE_ON_COUNT = {stateCharCount,stateCharCount};
		_SITE_ON_COUNT = matrixTrick2*(_OBSERVED_NS_$siteDifferenceCount)*Transpose(matrixTrick2);
		return (_SITE_ON_COUNT[0]+_SITE_OS_COUNT[0])/filteredData.sites;
	}
	return 0;
}
