b3129704a8afccbcb4436ad32465c4d07c56f01c angie Thu Jun 23 12:40:06 2016 -0700 Adjust to the new possibility of genbank table names having a database prefix, e.g. hgFixed.refSeqStatus. I considered libifying the new genbank functions but Braney is working on a similar situation in parallel so I'll keep them local for now. refs #17597 diff --git src/hg/hgVai/hgVai.c src/hg/hgVai/hgVai.c index 7b70949..34cf4e0 100644 --- src/hg/hgVai/hgVai.c +++ src/hg/hgVai/hgVai.c @@ -1,29 +1,31 @@ /* hgVai - Variant Annotation Integrator. */ /* Copyright (C) 2014 The Regents of the University of California * See README in this or parent directory for licensing information. */ #include "common.h" #include "linefile.h" #include "hash.h" #include "options.h" #include "jksql.h" #include "htmshell.h" #include "web.h" #include "cheapcgi.h" #include "cart.h" #include "cartTrackDb.h" +#include "genbank.h" +#include "hgConfig.h" #include "hui.h" #include "grp.h" #include "hCommon.h" #include "hgFind.h" #include "hPrint.h" #include "jsHelper.h" #include "memalloc.h" #include "textOut.h" #include "trackHub.h" #include "hubConnect.h" #include "twoBit.h" #include "gpFx.h" #include "bigGenePred.h" #include "udc.h" #include "knetUdc.h" @@ -772,39 +774,72 @@ return slNameCloneList(tagVersions); } boolean knownGeneHasGencodeTags() /* Return TRUE if this database has knownToTag for knownGene. */ { return hTableExists(database, "knownGene") && hTableExists(database, "knownToTag"); } boolean hasGencodeTags() /* Return TRUE if GENCODE tags can be associated with some gene track in database. */ { return knownGeneHasGencodeTags() || (getGencodeTagVersions() != NULL); } +void genbankGetDbTable(char *db, char *gbTable, char **retGenbankDb, char **retTableName) +/* Genbank tables (e.g. gbCdnaInfoTable) may now include a 'db.' prefix, e.g. + * hgFixed.gbCdnaInfo. If so, separate out the database and table name. If gbTable + * does not have a 'db.' prefix then use the configured genbankDb if given, else db. */ +{ +char *genbankDb = cfgOptionEnv("GENBANKDB", "genbankDb"); +char *tableName = gbTable; +char tableCopy[strlen(gbTable)+1]; +safecpy(tableCopy, sizeof(tableCopy), gbTable); +char *words[2]; +int wordCount = chopByChar(tableCopy, '.', words, ArraySize(words)); +if (wordCount == 2) + { + genbankDb = words[0]; + tableName = words[1]; + } +else if (isEmpty(genbankDb)) + genbankDb = db; +if (retGenbankDb) + *retGenbankDb = cloneString(genbankDb); +if (retTableName) + *retTableName = cloneString(tableName); +} + +boolean genbankTableExists(char *db, char *gbTable) +/* Return TRUE if table (which may or may not be prefixed by genbankDb) exists in + * genbankDb or db. */ +{ +char *genbankDb=NULL, *tableName=NULL; +genbankGetDbTable(db, gbTable, &genbankDb, &tableName); +return hTableExists(genbankDb, tableName); +} + boolean hasTxStatus() /* Return TRUE if any gene track in database has some kind of transcript status info * like knownCanonical, GENCODE tags and/or RefSeq status. */ { if (hasGencodeTags()) return TRUE; if (hTableExists(database, "knownGene") && hTableExists(database, "knownCanonical")) return TRUE; -if (hTableExists(database, "refGene") && hTableExists(database, "refSeqStatus")) +if (hTableExists(database, "refGene") && genbankTableExists(database, refSeqStatusTable)) return TRUE; return FALSE; } char *getLatestGencodeVersion(struct slName *versionList) /* Return the numerically largest version found in versionList. */ { int maxVersionNum = -1; char *maxVersion = NULL; struct slName *version; for (version = versionList; version != NULL; version = version->next) { int versionNum = atoi(skipToNumeric(version->name)); if (versionNum > maxVersionNum) { @@ -893,31 +928,31 @@ { boolean isVisible = sameString(geneTrack, "knownGene"); somethingIsVisible |= isVisible; printf("