84fc7dd7df5303df374f00530a8d590ae550e5db
angie
  Wed Aug 10 08:12:11 2011 -0700
Feature #3710 (vcfTabix UI options): added option to use pgSnp colors instead of blueRef/redAlt in haplotype sorting display.
diff --git src/hg/lib/vcfUi.c src/hg/lib/vcfUi.c
index 7e5a371..434c6fc 100644
--- src/hg/lib/vcfUi.c
+++ src/hg/lib/vcfUi.c
@@ -140,59 +140,83 @@
 struct errCatch *errCatch = errCatchNew();
 if (errCatchStart(errCatch))
     {
     vcff = vcfTabixFileMayOpen(fileOrUrl, NULL, 0, 0, vcfMaxErr);
     }
 errCatchEnd(errCatch);
 if (errCatch->gotError)
     {
     if (isNotEmpty(errCatch->message->string))
 	warn("unable to open %s: %s", fileOrUrl, errCatch->message->string);
     }
 errCatchFree(&errCatch);
 return vcff;
 }
 
+static void vcfCfgHapClusterEnable(struct cart *cart, struct trackDb *tdb, char *name,
+				   boolean compositeLevel)
+/* Let the user enable/disable haplotype sorting display. */
+{
+printf("<B>Enable Haplotype sorting display: </B>");
+boolean hapClustEnabled = cartUsualBooleanClosestToHome(cart, tdb, compositeLevel,
+							VCF_HAP_ENABLED_VAR, TRUE);
+char varName[1024];
+safef(varName, sizeof(varName), "%s." VCF_HAP_ENABLED_VAR, name);
+cgiMakeCheckBox(varName, hapClustEnabled);
+printf("<BR>\n");
+}
+
+static void vcfCfgHapClusterColor(struct cart *cart, struct trackDb *tdb, char *name,
+				   boolean compositeLevel)
+/* Let the user choose how to color the sorted haplotypes. */
+{
+printf("<B>Color sorted haplotypes by:</B>\n");
+char *colorBy = cartUsualStringClosestToHome(cart, tdb, compositeLevel,
+					     VCF_HAP_COLORBY_VAR, VCF_HAP_COLORBY_REFALT);
+boolean colorByRefAlt = sameString(colorBy, VCF_HAP_COLORBY_REFALT);
+char varName[1024];
+safef(varName, sizeof(varName), "%s." VCF_HAP_COLORBY_VAR, name);
+cgiMakeRadioButton(varName, VCF_HAP_COLORBY_REFALT, colorByRefAlt);
+printf("reference/alternate alleles (reference = blue, alternate = red)\n");
+cgiMakeRadioButton(varName, VCF_HAP_COLORBY_BASE, !colorByRefAlt);
+printf("first base of allele (A = red, C = blue, G = green, T = magenta)<BR>\n");
+}
+
 static void vcfCfgHapClusterHeight(struct cart *cart, struct trackDb *tdb, struct vcfFile *vcff,
 				   char *name, boolean compositeLevel)
 /* Let the user specify a height for the track. */
 {
 if (vcff != NULL && vcff->genotypeCount > 1)
     {
     printf("<B>Haplotype sorting display height:</B> \n");
     int cartHeight = cartUsualIntClosestToHome(cart, tdb, compositeLevel,
 					       VCF_HAP_HEIGHT_VAR, VCF_DEFAULT_HAP_HEIGHT);
     char varName[1024];
     safef(varName, sizeof(varName), "%s." VCF_HAP_HEIGHT_VAR, name);
     cgiMakeIntVarInRange(varName, cartHeight, "Height (in pixels) of track", 5, "10", "2500");
     }
 }
 
 static void vcfCfgHapCluster(struct cart *cart, struct trackDb *tdb, struct vcfFile *vcff,
 			     char *name)
 /* Show controls for haplotype-sorting display, which only makes sense to do when
  * the VCF file describes multiple genotypes. */
 {
 boolean compositeLevel = isNameAtCompositeLevel(tdb, name);
-printf("<B>Enable Haplotype sorting display: </B>");
-boolean hapClustEnabled = cartUsualBooleanClosestToHome(cart, tdb, compositeLevel,
-							VCF_HAP_ENABLED_VAR, TRUE);
-char varName[1024];
-safef(varName, sizeof(varName), "%s." VCF_HAP_ENABLED_VAR, name);
-cgiMakeCheckBox(varName, hapClustEnabled);
-printf("<BR>\n");
+vcfCfgHapClusterEnable(cart, tdb, name, compositeLevel);
 vcfCfgHaplotypeCenter(cart, tdb, vcff, NULL, NULL, 0, "mainForm");
+vcfCfgHapClusterColor(cart, tdb, name, compositeLevel);
 vcfCfgHapClusterHeight(cart, tdb, vcff, name, compositeLevel);
 //      thicken lines?
 //      outline center variant?
 //      color haplotypes by red/blue or allele bases?
 }
 
 void vcfCfgUi(struct cart *cart, struct trackDb *tdb, char *name, char *title, boolean boxed)
 /* VCF: Variant Call Format.  redmine #3710 */
 {
 boxed = cfgBeginBoxAndTitle(tdb, boxed, title);
 printf("<TABLE%s><TR><TD>", boxed ? " width='100%'" : "");
 struct vcfFile *vcff = vcfHopefullyOpenHeader(cart, tdb);
 if (vcff != NULL)
     {
     if (vcff->genotypeCount > 1)