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/hgBlat/hgBlat.c src/hg/hgBlat/hgBlat.c index f937ce3..6367734 100644 --- src/hg/hgBlat/hgBlat.c +++ src/hg/hgBlat/hgBlat.c @@ -61,7 +61,7 @@ char dbActualName[32]; /* If necessary convert database description to name. */ -sprintf(query, "select name from dbDb where name = '%s'", db); +safef(query, sizeof(query), "select name from dbDb where name = '%s'", db); if (!sqlExists(conn, query)) { sprintf(query, "select name from dbDb where description = '%s'", db); @@ -70,7 +70,7 @@ } /* Do a little join to get data to fit into the serverTable. */ -sprintf(query, "select dbDb.name,dbDb.description,blatServers.isTrans" +safef(query, sizeof(query), "select dbDb.name,dbDb.description,blatServers.isTrans" ",blatServers.host,blatServers.port,dbDb.nibPath " "from dbDb,blatServers where blatServers.isTrans = %d and " "dbDb.name = '%s' and dbDb.name = blatServers.db", @@ -95,6 +95,41 @@ return &st; } +void findClosestServer(char **pDb, char **pOrg) +/* If db doesn't have a blat server, look for the closest db (or org) that has one, + * as hgPcr does. */ +{ +char *db = *pDb, *org = *pOrg; +struct sqlConnection *conn = hConnectCentral(); +char query[256]; +safef(query, sizeof(query), "select db from blatServers where db = '%s'", db); +if (!sqlExists(conn, query)) + { + safef(query, sizeof(query), "select blatServers.db from blatServers,dbDb " + "where blatServers.db = dbDb.name and dbDb.genome = '%s'", org); + char *db = sqlQuickString(conn, query); + if (db == NULL) + { + safef(query, sizeof(query), "select blatServers.db from blatServers,dbDb " + "where blatServers.db = dbDb.name order by dbDb.orderKey,dbDb.name"); + char *db = sqlQuickString(conn, query); + if (db == NULL) + errAbort("central database tables blatServers and dbDb are disjoint/empty"); + else + { + *pDb = db; + *pOrg = hGenome(db); + } + } + else + { + *pDb = db; + *pOrg = hGenome(db); + } + } +hDisconnectCentral(&conn); +} + void usage() /* Explain usage and exit. */ { @@ -751,6 +786,8 @@ dnaUtilOpen(); getDbAndGenome(cart, &db, &organism, oldVars); +char *oldDb = cloneString(db); +findClosestServer(&db, &organism); /* Get sequence - from userSeq variable, or if * that is empty from a file. */ @@ -767,6 +804,10 @@ if (isEmpty(userSeq) || orgChange) { cartWebStart(theCart, db, "%s BLAT Search", organism); + if (differentString(oldDb, db)) + printf("

Note: BLAT search is not available for %s %s; " + "defaulting to %s %s


\n", + hGenome(oldDb), hFreezeDate(oldDb), organism, hFreezeDate(db)); askForSeq(organism,db); cartWebEnd(); }