644e660c5f6db00acf08433f9a7ed09738e13488
braney
  Sun Mar 8 18:57:44 2015 -0700
add a menu in hgTracksUi to let folks choose a coalescent ancestor when
resolving duplications (per Joel)

diff --git src/hg/hgTrackUi/hgTrackUi.c src/hg/hgTrackUi/hgTrackUi.c
index 9e1e993..01d6e4f 100644
--- src/hg/hgTrackUi/hgTrackUi.c
+++ src/hg/hgTrackUi/hgTrackUi.c
@@ -35,30 +35,34 @@
 #include "hapmapSnps.h"
 #include "nonCodingUi.h"
 #include "expRecord.h"
 #include "wikiTrack.h"
 #include "hubConnect.h"
 #include "trackHub.h"
 #include "pcrResult.h"
 #include "dgv.h"
 #include "transMapStuff.h"
 #include "vcfUi.h"
 #include "bbiFile.h"
 #include "ensFace.h"
 #include "microarray.h"
 #include "trackVersion.h"
 
+#ifdef USE_HAL
+#include "halBlockViz.h"
+#endif
+
 #define MAIN_FORM "mainForm"
 #define WIGGLE_HELP_PAGE  "../goldenPath/help/hgWiggleTrackHelp.html"
 
 
 struct cart *cart = NULL;	/* Cookie cart with UI settings */
 char *database = NULL;		/* Current database. */
 char *chromosome = NULL;        /* Chromosome. */
 struct hash *trackHash = NULL;	/* Hash of all tracks in database. */
 
 void tfbsConsSitesUi(struct trackDb *tdb)
 {
 float tfbsConsSitesCutoff =
     sqlFloat(cartUsualString(cart,TFBS_SITES_CUTOFF,TFBS_SITES_CUTOFF_DEFAULT));
 printf("<BR><B>Z score cutoff (default %s, minimum %s):&nbsp;</B>",
 	TFBS_SITES_CUTOFF_DEFAULT, TFBS_SITES_CUTOFF_MINIMUM);
@@ -2763,30 +2767,67 @@
                 hTvFromString(cartUsualString(cart, tdb->track, hStringFromTv(tdb->visibility)));
         hTvDropDownClassVisOnly(tdb->track, tv, tdb->canPack,
                                 tv == tvHide ?  "hiddenText" : "normalText",
                                 trackDbSetting(tdb, "onlyVisibility"));
         }
     #endif///ndef SUPERS_WITH_CHECKBOXES
     printf("<TD>%s", tdb->longLabel);
     char *dataVersion = trackDbSetting(tdb, "dataVersion");
     if (dataVersion)
         printf("&nbsp&nbsp;<EM style='color:#666666; font-size:smaller;'>%s</EM>", dataVersion);
     printf("</TD></TR>");
     }
 printf("</TABLE>");
 }
 
+#ifdef USE_HAL
+static void cfgHalSnake(struct trackDb *tdb, char *name)
+{
+boolean parentLevel = isNameAtParentLevel(tdb, name);
+if (parentLevel)
+    return;
+char *fileName = trackDbSetting(tdb, "bigDataUrl");
+char *errString;
+int handle = halOpenLOD(fileName, &errString);
+struct hal_species_t *speciesList, *sp;
+char *otherSpecies = trackDbSetting(tdb, "otherSpecies");
+extern char *database;
+
+speciesList = halGetPossibleCoalescenceLimits(handle, otherSpecies, 
+    trackHubSkipHubName(database), &errString);
+
+int count = 0;
+for(sp=speciesList; sp; sp = sp->next)
+    count++;
+
+char codeVarName[1024];
+safef(codeVarName, sizeof codeVarName, "%s.coalescent", tdb->track);
+char **ancestors;
+AllocArray(ancestors, count);
+count = 0;
+for(sp=speciesList; sp; sp = sp->next)
+    {
+    ancestors[count] = sp->name;
+    count++;
+    }
+char *coalescent = cartOptionalString(cart, codeVarName);
+printf("<B>Set Coalescent Ancestor to:</B>");
+cgiMakeDropListFull(codeVarName, ancestors, ancestors,
+    count, coalescent, NULL);
+}
+#endif
+
 void specificUi(struct trackDb *tdb, struct trackDb *tdbList, struct customTrack *ct, boolean ajax)
 /* Draw track specific parts of UI. */
 {
 char *track = tdb->track;
 // Ideally check cfgTypeFromTdb()/cfgByCfgType() first, but with all these special cases already in
 //    place, lets be cautious at this time.
 // NOTE: Developer, please try to use cfgTypeFromTdb()/cfgByCfgType().
 
 boolean boxed = trackDbSettingClosestToHomeOn(tdb, "boxedCfg");
 // UI precedence:
 // 1) supers to get them out of the way: they have no controls
 // 2) special cases based upon track name (developer please avoid)
 // 3) cfgTypeFromTdb()/cfgByCfgType() <== prefered method
 // 4) special cases falling through the cracks but based upon type
 if (tdbIsSuperTrack(tdb))
@@ -2929,30 +2970,34 @@
      ||  sameString(track, "intronEst")
      ||  sameString(track, "xenoMrna")
      ||  sameString(track, "xenoEst"))
     mrnaCfgUi(cart, tdb, tdb->track, NULL, boxed);
 else if (sameString(track, "lrg"))
     lrgCfgUi(cart, tdb, tdb->track, NULL, boxed);
 else if (sameString(track, "lrgTranscriptAli"))
     lrgTranscriptAliCfgUi(cart, tdb, tdb->track, NULL, boxed);
 else if (tdb->type != NULL)
     {   // NOTE for developers: please avoid special cases and use cfgTypeFromTdb//cfgByCfgType()
         //  When you do, then multi-view cfg and subtrack cfg will work.
     eCfgType cType = cfgTypeFromTdb(tdb,FALSE);
     if (cType != cfgNone)
         {
         cfgByCfgType(cType,database, cart, tdb,tdb->track, NULL, boxed);
+#ifdef USE_HAL
+	if (cType == cfgSnake)
+	    cfgHalSnake(tdb, tdb->track);
+#endif
         }
     // NOTE: these cases that fall through the cracks should probably get folded into cfgByCfgType()
     else if (startsWithWord("expRatio", tdb->type))
         expRatioUi(tdb);
     else if (startsWith("chromGraph", tdb->type))
         chromGraphUi(tdb);
     else if (startsWith("sample", tdb->type))
         genericWiggleUi(tdb,7);
     else if (startsWithWord("array",tdb->type)) // not quite the same as "expRatio" (custom tracks)
         expRatioCtUi(tdb);
     else if (startsWithWord("factorSource",tdb->type))
         factorSourceUi(database,tdb);
     }
 
 if (!ajax) // ajax asks for a simple cfg dialog for right-click popup or hgTrackUi subtrack cfg