0a9372ad1d6c6498fd3818a91edb65d932d890d9
angie
  Thu Apr 2 11:37:11 2020 -0700
VCF: new option to display haplotypes ordered by a trackDb-specified Newick tree file.  Tree is drawn in left label area.  refs #25278

diff --git src/hg/lib/vcfUi.c src/hg/lib/vcfUi.c
index 48ca85f..7cfd5e8 100644
--- src/hg/lib/vcfUi.c
+++ src/hg/lib/vcfUi.c
@@ -128,31 +128,40 @@
 if (vcff != NULL && vcff->genotypeCount > 1)
     {
     printf("<TABLE cellpadding=0><TR><TD colspan=2>"
 	   "<B>Haplotype sorting order:</B></TD></TR><TR><TD>\n");
     char *hapMethod = cartOrTdbString(cart, tdb, VCF_HAP_METHOD_VAR, VCF_DEFAULT_HAP_METHOD);
     char varName[1024];
     safef(varName, sizeof(varName), "%s." VCF_HAP_METHOD_VAR, track);
     cgiMakeRadioButton(varName, VCF_HAP_METHOD_CENTER_WEIGHTED,
                        sameString(hapMethod, VCF_HAP_METHOD_CENTER_WEIGHTED));
     printf("</TD><TD>");
     vcfCfgHaplotypeCenter(cart, tdb, track, parentLevel, vcff, NULL, NULL, 0, "mainForm");
     puts("<TR><TD>");
     cgiMakeRadioButton(varName, VCF_HAP_METHOD_FILE_ORDER,
                        sameString(hapMethod, VCF_HAP_METHOD_FILE_ORDER));
     puts("</TD><TD>using the order in which samples appear in the underlying VCF file");
-    puts("</TR></TD></TABLE>");
+    // If trackDb specifies a treeFile, offer that as an option
+    char *hapMethodTdb = trackDbSetting(tdb, VCF_HAP_METHOD_VAR);
+    if (hapMethodTdb && startsWithWord("treeFile", hapMethodTdb))
+        {
+        puts("<TR><TD>");
+        cgiMakeRadioButton(varName, VCF_HAP_METHOD_TREE_FILE,
+                           startsWithWord(VCF_HAP_METHOD_TREE_FILE, hapMethod));
+        printf("</TD><TD>using the tree specified in file associated with track");
+        }
+    puts("</TD></TR></TABLE>");
     }
 }
 
 //TODO: share this code w/hgTracks, hgc in hg/lib/vcfFile.c
 static struct vcfFile *vcfHopefullyOpenHeader(struct cart *cart, struct trackDb *tdb)
 /* Defend against network errors and return the vcfFile object with header data, or NULL. */
 {
 knetUdcInstall();
 if (udcCacheTimeout() < 300)
     udcSetCacheTimeout(300);
 char *fileOrUrl = trackDbSetting(tdb, "bigDataUrl");
 if (isEmpty(fileOrUrl))
     {
     char *db = cartString(cart, "db");
     char *table = tdb->table;