a2c0a8eabeb1cc860b04688d176d4f309ca42d19 larrym Mon Apr 4 12:19:51 2011 -0700 add assemblyGeneSuggestTrack (used in fixing redmine #3483) diff --git src/hg/lib/suggest.c src/hg/lib/suggest.c index 2fce957..e7d2f04 100644 --- src/hg/lib/suggest.c +++ src/hg/lib/suggest.c @@ -1,20 +1,43 @@ /* code to support suggesting genes given a prefix typed by the user. */ #include "suggest.h" static char const rcsid[] = "$Id: suggest.c,v 1.3 2010/02/06 03:21:00 larrym Exp $"; -boolean connSupportsGeneSuggest(struct sqlConnection *conn) -// return true if this connection has tables to support gene autocompletion +static char *connGeneSuggestTable(struct sqlConnection *conn) +// return name of gene suggest table if this connection has tables to support gene autocompletion, NULL otherwise { -return sqlTableExists(conn, "knownCanonical") || sqlTableExists(conn, "refGene"); +if(sqlTableExists(conn, "knownCanonical")) + return "knownCanonical"; +else if(sqlTableExists(conn, "refGene")) + return "refGene"; +else + return NULL; } boolean assemblySupportsGeneSuggest(char *database) // return true if this assembly has tables to support gene autocompletion { struct sqlConnection *conn = hAllocConn(database); -boolean retval = connSupportsGeneSuggest(conn); +char *table = connGeneSuggestTable(conn); hFreeConn(&conn); -return retval; +return table != NULL; +} + +char *assemblyGeneSuggestTrack(char *database) +// return name of gene suggest track if this assembly has tables to support gene autocompletion, NULL otherwise +// Do NOT free returned string. +{ +struct sqlConnection *conn = hAllocConn(database); +char *table = connGeneSuggestTable(conn); +hFreeConn(&conn); +if(table != NULL) + { + if(sameString(table, "knownCanonical")) + return "knownGene"; + else + return "refGene"; + } +else + return NULL; }