1edaaa4d28813a698990929566228d330ce2b381 angie Mon Nov 15 14:41:11 2010 -0800 Track #1570 (search using OMIM id used in URL): added support forsingleSearch=omimGeneAcc, or any searchName (which defaults to searchTable if not defined in trackDb.ra). May not be strictly necessary for OMIM because as Fan found OMIM numeric IDs already get unique semiShortCircuit hits, but we expect this to be useful for track-specific links to us in general. diff --git src/hg/lib/hgFind.c src/hg/lib/hgFind.c index c6dfbb1..744ac91 100644 --- src/hg/lib/hgFind.c +++ src/hg/lib/hgFind.c @@ -2929,44 +2929,65 @@ "where kgXref.geneSymbol = '%s' and kgXref.kgId = knownCanonical.transcript;", term); struct sqlResult *sr = sqlGetResult(conn, query); char **row; if ((row = sqlNextRow(sr)) != NULL) { singlePos(hgp, "UCSC Genes", term, "knownGene", row[3], row[3], cloneString(row[0]), atoi(row[1]), atoi(row[2])); foundIt = TRUE; } sqlFreeResult(&sr); } hFreeConn(&conn); return foundIt; } +static struct hgFindSpec *hfsFind(struct hgFindSpec *list, char *name) +/* Return first element of list that matches name. */ +{ +struct hgFindSpec *el; +for (el = list; el != NULL; el = el->next) + if (sameString(name, el->searchName)) + return el; +return NULL; +} + + static boolean singleSearch(char *db, char *term, struct cart *cart, struct hgPositions *hgp) /* If a search type is specified in the CGI line (not cart), perform that search. * If the search is successful, fill in hgp as a single-pos result and return TRUE. */ { char *search = cgiOptionalString("singleSearch"); if (search == NULL) return FALSE; cartRemove(cart, "singleSearch"); boolean foundIt = FALSE; if (sameString(search, "knownCanonical")) foundIt = searchKnownCanonical(db, term, hgp); else + { + struct hgFindSpec *shortList = NULL, *longList = NULL; + hgFindSpecGetAllSpecs(db, &shortList, &longList); + struct hgFindSpec *hfs = hfsFind(shortList, search); + if (hfs == NULL) + hfs = hfsFind(longList, search); + if (hfs != NULL) + foundIt = hgFindUsingSpec(db, hfs, term, hgp, FALSE, 0,0, FALSE); + else warn("Unrecognized singleSearch=%s in URL", search); + } if (foundIt) { fixSinglePos(hgp); if (cart != NULL) cartSetString(cart, "hgFind.matches", hgp->tableList->posList->browserName); } return foundIt; } struct hgPositions *hgPositionsFind(char *db, char *term, char *extraCgi, char *hgAppNameIn, struct cart *cart, boolean multiTerm) /* Return table of positions that match term or NULL if none such. */ { struct hgPositions *hgp = NULL, *hgpItem = NULL; regmatch_t substrs[4];