2d3028934575643575ea1523ee3a3c0cd9d02430
angie
  Fri Oct 22 14:50:49 2010 -0700
Redmine Feature #1470 (create ability to not have a blat server for anassembly):
1. In hgBlat, if db does not have a blat server, search for an
alternate as hgPcr does: if there's a blat server for the same
organism, use that, otherwise just default to the db with a blat
server & the lowest dbDb.orderKey.  If we default to some other
db's blat server, notify the user.
2. In hgPcr, if we default to some other db's blat server, notify the user.
3. If db doesn't have a blat server, suppress the blat links in the
hot links bar in webStartWrapperDetailedInternal. (hgTracks.c's hot
links already did this).  Our static html hotlinks include Blat and
PCR links, so it is still necessary for hgBlat and hgPcr to handle
db's that don't have blat servers.
4. Also in webStartWrapperDetailedInternal, call getDbAndGenome (part
of uiState construction) *before* we test db for NULL and default
the local db variable to hDefaultDb.  When the defaulting happened
before getDbAndGenome (as in hgVisiGene which passes in NULL db),
db was hDefaultDb for a while and then the cart db, and the hot
links weren't constructed correctly.

diff --git src/hg/lib/web.c src/hg/lib/web.c
index 8afa230..9742f01 100644
--- src/hg/lib/web.c
+++ src/hg/lib/web.c
@@ -99,9 +99,30 @@
 boolean isEncode = FALSE;
 boolean isGsid   = hIsGsidServer();
 boolean isGisaid = hIsGisaidServer();
+if (theCart)
+    {
+    char *theGenome = NULL;
+    char *genomeEnc = NULL;
+
+    getDbAndGenome(theCart, &db, &theGenome, NULL);
+    genomeEnc = cgiEncode(theGenome);
+
+    safef(uiState, sizeof(uiState), "?%s=%s&%s=%s&%s=%u",
+	     orgCgiName, genomeEnc,
+	     dbCgiName, db,
+	     cartSessionVarName(), cartSessionId(theCart));
+    }
+else
+    {
+    uiState[0] = 0;
+    uiState[1] = 0;
+    }
 if (db == NULL)
     db = hDefaultDb();
 boolean dbIsFound = hDbExists(db);
+boolean haveBlat = FALSE;
+if (dbIsFound)
+    haveBlat = hIsBlatIndexedDatabase(db);
 
 if (scriptName == NULL)
     scriptName = cloneString("");
@@ -182,24 +203,6 @@
     puts("</TH></TR>" "\n"
     	 "" "\n" );
     }
-if (theCart)
-    {
-    char *theGenome = NULL;
-    char *genomeEnc = NULL;
-
-    getDbAndGenome(theCart, &db, &theGenome, NULL);
-    genomeEnc = cgiEncode(theGenome);
-
-    safef(uiState, sizeof(uiState), "?%s=%s&%s=%s&%s=%u",
-	     orgCgiName, genomeEnc,
-	     dbCgiName, db,
-	     cartSessionVarName(), cartSessionId(theCart));
-    }
-else
-    {
-    uiState[0] = 0;
-    uiState[1] = 0;
-    }
 
 /* Put up the hot links bar. */
 if (isGisaid)
@@ -211,6 +214,7 @@
     printf("<TD ALIGN=CENTER><A HREF=\"../index.html\" class=\"topbar\"><FONT COLOR=\"#FFFFFF\">Home</FONT></A></TD>");
 
     /* Blat */
+    if (haveBlat)
     printf("<TD ALIGN=CENTER><A HREF=\"../cgi-bin/hgBlat?command=start\" class=\"topbar\"><FONT COLOR=\"#FFFFFF\">Blat</FONT></A></TD>");
 
     /* Subject  View */
@@ -247,6 +251,7 @@
     printf("<TD ALIGN=CENTER><A HREF=\"../index.html\" class=\"topbar\"><FONT COLOR=\"#FFFFFF\">Home</FONT></A></TD>");
 
     /* Blat */
+    if (haveBlat)
     printf("<TD ALIGN=CENTER><A HREF=\"../cgi-bin/hgBlat?command=start\" class=\"topbar\"><FONT COLOR=\"#FFFFFF\">Blat</FONT></A></TD>");
 
     /* Subject  View */
@@ -313,7 +318,7 @@
 	       uiState,searchTracks);
 	puts("           Genome Browser</A> &nbsp;&nbsp;&nbsp;");
 	}
-    if (!endsWith(scriptName, "hgBlat"))
+    if (haveBlat && !endsWith(scriptName, "hgBlat"))
 	{
     	printf("       <A HREF=\"../cgi-bin/hgBlat?command=start%s%s\" class=\"topbar\">",
 		theCart ? "&" : "", uiState+1 );