selLabelMatrixSA = {{"Site1","Site2","P{S1&rarr;S2}","E[S1&rarr;S2]","P{S1&larr;S1}","E[S1&larr;S2]","P{S1&harr;S2}","E[S1&harr;S2]","% of supporting replicates"}};
selLabelMatrix   = {{"Site1","Site2","P{S&rarr;S2}","P{S1&larr;S2}","P{S1&harr;S2}"}};

selLabelMatrixSACSV   = {{"Site1","Site2","P{S1->S2}","E[S1->S2]","P{S1->S1}","E[S1->S2]","P{S1<->S2}","E[S1<->S2]","% of supporting replicates"}};
selLabelMatrixCSV    = {{"Site1","Site2","P{S->S2}","P{S1<-S2}","P{S1<->S2}"}};

BGM_ResultTable 				 = {};
BGM_ResultTable ["Codon1"] 		 = "INTEGER";
BGM_ResultTable ["Codon2"]    	 = "INTEGER";
BGM_ResultTable ["Edge12"]    	 = "REAL";
BGM_ResultTable ["Edge21"]   	 = "REAL";
BGM_ResultTable ["E12"]    	 	 = "REAL";
BGM_ResultTable ["E21"]   	 	 = "REAL";

BGM_SATable 				 	 = {};
BGM_SATable ["Codon1"] 		 	 = "INTEGER";
BGM_SATable ["Codon2"]    	 	 = "INTEGER";
BGM_SATable ["Replicate"]    	 = "INTEGER";
BGM_SATable ["Edge12"]    		 = "REAL";
BGM_SATable ["Edge21"]   	 	 = "REAL";

keyMapSA 	= {{"Codon1","Codon2","Edge12","E12","Edge21","E21","SUM","ET","Support"}};
keyMapPLAIN = {{"Codon1","Codon2","Edge12","Edge21","SUM"}};


tableLegendBasicHead = "<dl><dt class = 'DMDT' style = 'font-size:10px'>Site1, Site 2<dd style = 'font-size:10px'>Coordinates of each of the interacting residues"
					 + "<dt class = 'DMDT' style = 'font-size:10px'>P{S1&rarr;S2}<dd style = 'font-size:10px'>Posterior probability for site 2 being conditionally dependent on site 1 "
					 + "<dt class = 'DMDT' style = 'font-size:10px'>P{S1&larr;S2}<dd style = 'font-size:10px'>Posterior probability for site 1 being conditionally dependent on site 2 "
					 + "<dt class = 'DMDT' style = 'font-size:10px'>P{S1&harr;S2}<dd style = 'font-size:10px'>Posterior probability for site 1 and site 2 being conditionally dependent";
					 					 
tableLegendExtra	 = "<dt class = 'DMDT' style = 'font-size:10px'>E[S1&rarr;S2],E[S1&larr;S2] and E[S1&harr;S2]<dd style = 'font-size:10px'>The mean posterior probability for the respective quantity over all ancestral samples" +
					   "<dt class = 'DMDT' style = 'font-size:10px'>% of supporting replicates<dd style = 'font-size:10px'>The percentage of ancestral replicates that have P{S1&harr;S2} &#8805; that of the maximum likelihood ancestral state";

tableLegendBasicFoot = "</dl>";

/*___________________________________________________________________________________________________________*/

function	PrintASCIITable (dataMatrix, titleMatrix, doSLACMaps)
{
	outString="";
	outString*8192;
	if (Rows(dataMatrix))
	{
		outString*"<DIV CLASS='RepClassSM'>\n<TABLE BORDER = '0'><TR CLASS='TRReport' style = 'font-size:10px;'>";
		nc = Columns(titleMatrix);
		for (counter1=0; counter1<nc; counter1 = counter1+1)
		{
			outString*"<td>";
			outString*titleMatrix[counter1];
			outString*"</td>\n";
		}
		
		if (doSLACMaps)
		{
			outString*"<td>Compare sites</td></tr>\n";
		}
		else
		{
			outString*"</tr>\n";
		}	
		
		colCount = Columns(titleMatrix);
		
		for (counter1=0; counter1<Rows(dataMatrix); counter1 = counter1 + 1)
		{
			if (counter1%2)
			{
				outString*"\n<tr CLASS='TRReport2' style = 'font-size:x-small'>";
			}
			else
			{
				outString*"\n<tr CLASS='TRReport1' style = 'font-size:x-small'>";
			}
			
			for (counter2 = 0; counter2 < colCount; counter2 = counter2+1)
			{
				outString*"\n<td>";
				outString*Format(dataMatrix[counter1][counter2],-1,-1);
				outString*"\n</td>\n";
			}

			if (doSLACMaps)
			{
				codonIndex  = dataMatrix[counter1][0]-1;
				codonIndex2 = dataMatrix[counter1][1]-1;


				if (genCodeID >= 0)
				{
					outString*("<TD style = 'font-size: 10px;'><a href='"+BASE_CGI_URL_STRING+"siteMap.pl?file="+filePrefix+"&site="+codonIndex+"-"+codonIndex2+"&mode=0'>[Codons]</a>"+
							   "<a href='"+BASE_CGI_URL_STRING+"siteMap.pl?file="+filePrefix+"&site="+codonIndex+"-"+codonIndex2+"&mode=1'>[AA]</a>"+
									 "<a href='"+BASE_CGI_URL_STRING+"siteMap.pl?file="+filePrefix+"&site="+codonIndex+"-"+codonIndex2+"&mode=2'>[Counts]</a>");
				}
				else
				{
					if (genCodeID == (-1))
					{
						outString*("<TD style = 'font-size: 10px;'<a href='"+BASE_CGI_URL_STRING+"siteMap.pl?file="+filePrefix+"&site="+codonIndex+"-"+codonIndex2+"&mode=0&dataType=1'>[Nucleotides]</a>"+
										 "<a href='"+BASE_CGI_URL_STRING+"siteMap.pl?file="+filePrefix+"&site="+codonIndex+"-"+codonIndex2+"&mode=2&dataType=1'>[Counts]</a>");
					}
					else
					{
						outString*("<TD style = 'font-size: 10px;'><a href='"+BASE_CGI_URL_STRING+"siteMap.pl?file="+filePrefix+"&site="+codonIndex+"-"+codonIndex2+"&mode=0&dataType=2'>[AA]</a>"+
										 "<a href='"+BASE_CGI_URL_STRING+"siteMap.pl?file="+filePrefix+"&site="+codonIndex+"-"+codonIndex2+"&mode=2&dataType=2'>[Counts]</a>");
					}
				
				}
			}
			else
			{
				outString*"</tr>\n";
			}
		}
		outString*"</TABLE></DIV>\n";	
	}
	outString*0;
	return outString;
}

