8e01434bfdc7b343d768e46efe31441e9a1e5229 kate Mon Nov 21 10:59:31 2016 -0800 Fix gene search with alternative item naming. refs #18412 diff --git src/hg/hgc/gtexClick.c src/hg/hgc/gtexClick.c index dab7f9a..c39e80c 100644 --- src/hg/hgc/gtexClick.c +++ src/hg/hgc/gtexClick.c @@ -24,42 +24,46 @@ if (geneClass == NULL) return unknown; if (sameString(geneClass, "coding")) return "#0C0C78"; if (sameString(geneClass, "nonCoding")) return "#006400"; if (sameString(geneClass, "pseudo")) return "#FF33FF"; if (sameString(geneClass, "problem")) return "#FE0000"; return unknown; } static struct gtexGeneBed *getGtexGene(char *item, char *chrom, int start, int end, char *table) -/* Retrieve gene info for this item from the main track table */ +/* Retrieve gene info for this item from the main track table. + * Item name may be gene name, geneId or name/geneId */ { struct gtexGeneBed *gtexGene = NULL; struct sqlConnection *conn = hAllocConn(database); char **row; char query[512]; struct sqlResult *sr; if (sqlTableExists(conn, table)) { - sqlSafef(query, sizeof query, "SELECT * FROM %s WHERE name = '%s' AND chrom = '%s' " - " and chromStart = %d and chromEnd = %d", - table, item, chrom, start, end); + char *geneId = stringIn("ENSG", item); + sqlSafef(query, sizeof query, + "SELECT * FROM %s WHERE %s = '%s' " + "AND chrom = '%s' AND chromStart = %d AND chromEnd = %d", + table, geneId ? "geneId" : "name", geneId ? geneId : item, + chrom, start, end); sr = sqlGetResult(conn, query); row = sqlNextRow(sr); if (row != NULL) { gtexGene = gtexGeneBedLoad(row); } sqlFreeResult(&sr); } hFreeConn(&conn); return gtexGene; } char *getGeneDescription(struct gtexGeneBed *gtexGene) /* Get description for gene. Needed because knownGene table semantics have changed in hg38 */ {