95d61c93a898b6f56b2dee2aca4408cf0b02c1a1
angie
  Wed Nov 23 14:43:54 2011 -0800
Feature #3711 (VCF haplotype-sorting display): Fixed a silly boundary& rounding error in pixel loop.  Also, use lower case for alternate
allele in cluster mouseovers so the relationship to blue and red pixels
is more clear.

diff --git src/hg/hgTracks/vcfTrack.c src/hg/hgTracks/vcfTrack.c
index 610e493..cbe089a 100644
--- src/hg/hgTracks/vcfTrack.c
+++ src/hg/hgTracks/vcfTrack.c
@@ -551,36 +551,33 @@
 		       struct track *tg, struct hvGfx *hvg, int xOff, int yOff, int width,
 		       boolean isCenter, boolean colorByRefAlt)
 /* Draw a stack of genotype bars for this record */
 {
 const double scale = scaleForPixels(width);
 int x1 = round((double)(rec->chromStart-winStart)*scale) + xOff;
 int x2 = round((double)(rec->chromEnd-winStart)*scale) + xOff;
 int w = x2-x1;
 if (w <= 1)
     {
     x1--;
     w = 3;
     }
 double hapsPerPix = (double)gtHapCount / (tg->height-1);
 int pixIx;
-for (pixIx = 0;  pixIx < tg->height;  pixIx++)
+for (pixIx = 0;  pixIx < tg->height-1;  pixIx++)
     {
-    int gtHapOrderIxStart = round(hapsPerPix * pixIx);
-    // Watch out for overflow:
-    if (gtHapOrderIxStart >= gtHapCount)
-	break;
+    int gtHapOrderIxStart = (int)(hapsPerPix * pixIx);
     int gtHapOrderIxEnd = round(hapsPerPix * (pixIx + 1));
     if (gtHapOrderIxEnd == gtHapOrderIxStart)
 	gtHapOrderIxEnd++;
     int unks = 0, refs = 0, alts = 0;
     int gtHapOrderIx;
     for (gtHapOrderIx = gtHapOrderIxStart;  gtHapOrderIx < gtHapOrderIxEnd;  gtHapOrderIx++)
 	{
 	int gtHapIx = gtHapOrder[gtHapOrderIx];
 	int hapIx = gtHapIx & 1;
 	int gtIx = gtHapIx >>1;
 	struct vcfGenotype *gt = &(rec->genotypes[gtIx]);
 	if (!gt->isPhased && gt->hapIxA != gt->hapIxB)
 	    unks++;
 	else
 	    {
@@ -843,31 +840,32 @@
 th->track = track;
 th->startIx = startIx;
 th->centerIx = centerIx;
 th->endIx = endIx;
 th->nRecords = nRecords;
 int len = endIx - startIx;
 AllocArray(th->refs, len);
 AllocArray(th->alts, len);
 struct vcfRecord *rec;
 int i;
 for (rec = vcff->records, i = 0;  rec != NULL && i < endIx;  rec = rec->next, i++)
     {
     if (i < startIx)
 	continue;
     th->refs[i-startIx] = rec->alleles[0];
-    th->alts[i-startIx] = rec->alleles[1];
+    th->alts[i-startIx] = cloneString(rec->alleles[1]);
+    tolowers(th->alts[i-startIx]);
     }
 }
 
 static void drawTreeInLabelArea(struct hacTree *ht, struct hvGfx *hvg, int yOff, int height,
 				struct yFromNodeHelper *yHelper, struct titleHelper *titleHelper)
 /* Draw the haplotype clustering in the left label area (as much as fits there). */
 {
 // Figure out which hvg to use, save current clipping, and clip to left label coords:
 struct hvGfx *hvgLL = (hvgSide != NULL) ? hvgSide : hvg;
 int clipXBak, clipYBak, clipWidthBak, clipHeightBak;
 hvGfxGetClip(hvgLL, &clipXBak, &clipYBak, &clipWidthBak, &clipHeightBak);
 hvGfxUnclip(hvgLL);
 hvGfxSetClip(hvgLL, leftLabelX, yOff, leftLabelWidth, height);
 // Draw the tree:
 int x = leftLabelX;