353f3dcddb9f04d1bbe300ea10f7d8b1026cd412 fanhsu Tue Jan 11 10:25:16 2011 -0800 Added logic of hgg_gene search for OMIM gene symbol. diff --git src/hg/hgGene/hgGene.c src/hg/hgGene/hgGene.c index c3c9534..de8c290 100644 --- src/hg/hgGene/hgGene.c +++ src/hg/hgGene/hgGene.c @@ -484,30 +484,57 @@ sectionList = loadSectionList(conn); printIndex(sectionList); printSections(sectionList, conn, curGeneId); } static char *findGeneId(struct sqlConnection *conn, char *name) /* Given some sort of gene name, see if it is in our primary gene table, and if not * look it up in alias table if we have one. */ { /* Just check if it's in the main gene table, and if so return input name. */ char *mainTable = genomeSetting("knownGene"); char query[256]; safef(query, sizeof(query), "select count(*) from %s where name = '%s'", mainTable, name); if (sqlQuickNum(conn, query) > 0) return name; +else + { + /* check OMIM gene symbol table first */ + if (sqlTableExists(conn, "omimGeneSymbol")) + { + safef(query, sizeof(query), "select geneSymbol from omimGeneSymbol where geneSymbol= '%s'", name); + char *symbol = sqlQuickString(conn, query); + if (symbol != NULL) + { + safef(query, sizeof(query), "select kgId from kgXref where geneSymbol = '%s'", symbol); + char *kgId = sqlQuickString(conn, query); + if (kgId != NULL) + { + /* The canonical gene is preferred */ + safef(query, sizeof(query), + "select c.transcript from knownCanonical c,knownIsoforms i where i.transcript = '%s' and i.clusterId=c.clusterId", kgId); + char *canonicalKgId = sqlQuickString(conn, query); + if (canonicalKgId != NULL) + { + return canonicalKgId; + } + else + return(kgId); + } + } + } + } char *alias = genomeOptionalSetting("kgAlias"); if (alias != NULL && sqlTableExists(conn, alias)) { safef(query, sizeof(query), "select kgID from %s where alias = '%s'", alias, name); char *id = sqlQuickString(conn, query); if (id == NULL) hUserAbort("Couldn't find %s in %s.%s or %s.%s", name, database, mainTable, database, alias); return id; } else hUserAbort("Couldn't find %s in %s.%s", name, database, mainTable); return NULL; }