ExecuteAFile (HYPHY_LIB_DIRECTORY+"TemplateBatchFiles"+DIRECTORY_SEPARATOR+"TemplateModels"+DIRECTORY_SEPARATOR+"chooseGeneticCode.def");

/* computing the map from achievable states to 21x21 */

defaultAAOrdering 	= "FLIMVSPTAYHQNKDECWRG";
hshift      		= 0;
mapUpTo2121 		= {};
isOneStepSub 		= {21,21};
matrixToVectorMap	= {20,20}["-1"];

for (h=0; h<64; h=h+1)
{
	if (_Genetic_Code[h]==10) 
	{
		hshift = hshift+1;
		continue; 
	}
	vshift = hshift;
	for (v = h+1; v<64; v=v+1)
	{
		diff = v-h;
		if (_Genetic_Code[v]==10) 
		{
			vshift = vshift+1;
			continue; 
		}
		if ((h$4==v$4)||((diff%4==0)&&(h$16==v$16))||(diff%16==0))
		{
			aa1 = _Genetic_Code[0][h];
			aa2 = _Genetic_Code[0][v];
			if (aa1 != aa2)
			{
				if (aa1 < aa2)
				{
					idx_mx = {{aa1,aa2}};
				}
				else
				{
					idx_mx = {{aa2,aa1}};
				}
				
				if (aa1>10) {aa1c = aa1-1;} else {aa1c = aa1;}
				if (aa2>10) {aa2c = aa2-1;} else {aa2c = aa2;}
				isOneStepSub [aa1c][aa2c] = 1;
				isOneStepSub [aa2c][aa1c] = 1;
				
				map_idx = mapUpTo2121 [idx_mx];
				if (map_idx == 0)
				{
					mapUpTo2121[idx_mx] = Abs(mapUpTo2121)+1;
					map_idx = Abs(mapUpTo2121);
					matrixToVectorMap[aa1c][aa2c] = map_idx-1;
					matrixToVectorMap[aa2c][aa1c] = map_idx-1;
				}
			}	
		}
    }
}	

stateVectorDimension = Abs(mapUpTo2121);
maxRateClasses		 = stateVectorDimension;
fprintf (stdout, "\n", stateVectorDimension, " one step reachable states\n");
