533112afe2a2005e80cdb1f82904ea65032d4302 braney Sat Oct 2 11:37:34 2021 -0700 split hg/lib into two separate libaries, one only used by the cgis diff --git src/hg/cgilib/suggest.c src/hg/cgilib/suggest.c new file mode 100644 index 0000000..fcf098b --- /dev/null +++ src/hg/cgilib/suggest.c @@ -0,0 +1,53 @@ +/* code to support suggesting genes given a prefix typed by the user. */ + +/* Copyright (C) 2014 The Regents of the University of California + * See README in this or parent directory for licensing information. */ + +#include "suggest.h" + + +char *connGeneSuggestTable(struct sqlConnection *conn) +// return name of gene suggest table if this connection has tables to support gene autocompletion, NULL otherwise +{ +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 +{ +char *knownDatabase = hdbDefaultKnownDb(database); +struct sqlConnection *conn = hAllocConn(knownDatabase); +char *table = connGeneSuggestTable(conn); +hFreeConn(&conn); +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. +{ +char *knownDatabase = hdbDefaultKnownDb(database); +struct sqlConnection *conn = hAllocConn(knownDatabase); +char *table = connGeneSuggestTable(conn); +hFreeConn(&conn); +if(table != NULL) + { + if(sameString(table, "knownCanonical")) + { + if (differentString(knownDatabase, database)) + { + return hdbGetMasterGeneTrack(knownDatabase); + } + return "knownGene"; + } + else + return "refGene"; + } +else + return NULL; +}