Index: src/hg/hgc/hgc.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgc/hgc.c,v
retrieving revision 1.1517
retrieving revision 1.1518
diff -b -B -U 4 -r1.1517 -r1.1518
--- src/hg/hgc/hgc.c	12 Mar 2009 19:22:32 -0000	1.1517
+++ src/hg/hgc/hgc.c	13 Mar 2009 21:29:22 -0000	1.1518
@@ -5727,13 +5727,16 @@
     {
     puts("<HR>");
     printf("<B>Other matches for these primers:</B><BR>\n");
     for (psl = otherPsls;  psl != NULL;  psl = psl->next)
+	{
+	puts("<BR>");
 	if (target != NULL)
 	    printPcrTargetMatch(target, psl, FALSE);
 	else
 	    printPosOnChrom(psl->tName, psl->tStart, psl->tEnd,
 			    psl->strand, FALSE, NULL);
+	}
     puts("<HR>");
     }
 printPcrSequence(target, itemPsl, fPrimer, rPrimer);
 
@@ -18315,9 +18318,9 @@
 float freq2 = 0.0;
 
 if (majorCount == 0)
     {
-    printf("<TR><TD>%s</TD><TD>not available</TD><TD>not available</TD></TR>\n", pop);
+    printf("<TR><TD>%s</TD><TD align=center>-</TD><TD align=center>-</TD></TR>\n", pop);
     return;
     }
 
 if (sameString(allele1, majorAllele))
@@ -18354,8 +18357,29 @@
 printf("</TR>\n");
 
 }
 
+void showHapmapAverageRow(char *label, float freq1)
+{
+float freq2 = 1.0 - freq1;
+printf("<TR><TD>%s</TD>", label);
+if (freq1 > 0.5)
+    {
+    printf("<TD bgcolor = \"lightgrey\" align=right>(%3.2f%%)</TD>", freq1*100);
+    printf("<TD align=right>(%3.2f%%)</TD>", freq2*100);
+    }
+else if (freq1 < 0.5)
+    {
+    printf("<TD align=right>(%3.2f%%)</TD>", freq1*100);
+    printf("<TD bgcolor = \"lightgrey\" align=right>(%3.2f%%)</TD>", freq2*100);
+    }
+else
+    {
+    printf("<TD align=right>(%3.2f%%)</TD>", freq1*100);
+    printf("<TD align=right>(%3.2f%%)</TD>", freq2*100);
+    }
+printf("</TR>\n");
+}
 
 void doHapmapSnpsSummaryTable(struct sqlConnection *conn, struct trackDb *tdb, char *itemName,
 			      boolean showOrtho)
 /* Use the hapmapAllelesSummary table (caller checks for existence) to display allele
@@ -18441,8 +18465,9 @@
 char *majorAlleles[HAP_PHASEIII_POPCOUNT];
 int majorCounts[HAP_PHASEIII_POPCOUNT], haploCounts[HAP_PHASEIII_POPCOUNT];
 int totalA1Count = 0, totalA2Count = 0, totalHaploCount = 0;
 float sumHet = 0.0;
+int sumA1A1 = 0, sumA1A2 = 0, sumA2A2 = 0;
 int popCount = 0;
 char *allele1 = NULL, *allele2 = NULL;
 for (i=0;  i < HAP_PHASEIII_POPCOUNT;  i++)
     {
@@ -18488,18 +18513,19 @@
 	totalA2Count += 2*item->homoCount2 + item->heteroCount;
 	totalHaploCount += haploCounts[i];
 	sumHet += ((float)item->heteroCount /
 		   (item->homoCount1 + item->homoCount2 + item->heteroCount));
+	sumA1A1 += item->homoCount1;
+	sumA1A2 += item->heteroCount;
+	sumA2A2 += item->homoCount2;
 	popCount++;
 	}
     }
 printf("<TR><TH>Population</TH> <TH>%s</TH> <TH>%s</TH></TR>\n", allele1, allele2);
 for (i=0;  i < HAP_PHASEIII_POPCOUNT;  i++)
     showOneHapmapRow(hapmapPhaseIIIPops[i], allele1, allele2, majorAlleles[i],
 		     majorCounts[i], haploCounts[i]);
-char *totalMajorAllele = (totalA1Count >= totalA2Count) ? allele1 : allele2;
-int totalMajorCount = max(totalA1Count, totalA2Count);
-showOneHapmapRow("Total", allele1, allele2, totalMajorAllele, totalMajorCount, totalHaploCount);
+showHapmapAverageRow("Average", (float)totalA1Count / totalHaploCount);
 printf("</TABLE>\n");
 
 printf("<BR><B>Average of populations' observed heterozygosities:</B> %3.2f%%<BR>\n",
        (100.0 * sumHet/popCount));

