avTreeCount = Rows ("Tree");

if (avTreeCount>=1)
{
	choices = {avTreeCount,2};
	for (k=0; k<avTreeCount;k=k+1)
	{
		GetString (tName, Tree, k);
		choices[k][0] = tName;
		choices[k][1] = "Tree "+tName;
	}
	
	ChoiceList (tIndex,"Partition tree rates into classes:",1,SKIP_NONE,choices);
	if (tIndex>=0)
	{
		GetString (tName, Tree, tIndex);
		ExecuteCommands ("tree_bn=BranchName("+tName+",-1);");
		SetDialogPrompt ("Branch partitioning file:");
		fscanf (PROMPT_FOR_FILE, "Raw", defString);
		ExecuteCommands (defString);
		mappedTypes = {};
		for (k=Columns(tree_bn)-2; k>=0; k=k-1)
		{
			bName = tree_bn[k];
			if (bName/"Node*")
			{
				mappedID = branchAssignments[bName];
			}
			else
			{
				mappedID = branchAssignments[bName&&1];			
			}
			if (mappedTypes[mappedID] == 0)
			{
				ExecuteCommands ("global dNdS"+mappedID+"=1;");
				mappedTypes[mappedID] = 1;
			}
			ExecuteCommands (tName+"."+bName+".nonSynRate:=dNdS"+mappedID+"*"+tName+"."+bName+".synRate;");
		}
	}
}



