aba8125cb532df17beb7c7c9bc8467a43d09e3d6
braney
  Wed Feb 10 13:39:27 2016 -0800
changes to allow for GenBank metadata to be held in a common table.  #16809

diff --git src/hg/hgc/mgcClick.c src/hg/hgc/mgcClick.c
index 6a9f3d5..c716f22 100644
--- src/hg/hgc/mgcClick.c
+++ src/hg/hgc/mgcClick.c
@@ -1,59 +1,60 @@
 /* mgcClick - click handling for MGC and ORFEome related tracks */
 
 /* Copyright (C) 2013 The Regents of the University of California 
  * See README in this or parent directory for licensing information. */
 #include "common.h"
 #include "hgc.h"
 #include "mgcClick.h"
 #include "ccdsClick.h"
 #include "ccdsGeneMap.h"
 #include "gbMiscDiff.h"
 #include "web.h"
 #include "genbank.h"
 #include "htmshell.h"
 #include "genePred.h"
 #include "geneSimilarities.h"
+#include "genbank.h"
 
 
 static char *findRefSeqSummary(struct sqlConnection *conn,
                                struct geneSimilarities *refSeqs,
                                char **sumAccv)
 /* Given similar refseq genes, find the first one with a RefSeq
  * summary and return that summary, or NULL if not found.  Also returns
  * accv of matched */
 {
 char buf[GENBANK_ACC_BUFSZ];
 struct geneSim *rs;
 for (rs = refSeqs->genes; rs != NULL; rs = rs->next)
     {
     char *sum = getRefSeqSummary(conn, genbankDropVer(buf, rs->gene->name));
     if (sum != NULL)
         {
         *sumAccv = cloneString(rs->gene->name);
         return sum;
         }
     }
 *sumAccv = NULL;
 return NULL;
 }
 
 static char *getAccVersion(struct sqlConnection *conn, char *acc)
 /* given a accession, get acc.ver */
 {
 char query[256], accver[64];
-sqlSafef(query, sizeof(query), "SELECT version FROM gbCdnaInfo WHERE acc=\"%s\"", acc);
+sqlSafef(query, sizeof(query), "SELECT version FROM %s WHERE acc=\"%s\"", gbCdnaInfoTable, acc);
 safef(accver, sizeof(accver), "%s.%d", acc, sqlNeedQuickNum(conn, query));
 return cloneString(accver);
 }
 
 struct mgcDb
 /* information about an MGC databases */
 {
     char *name;       /* collection name */
     char *title;      /* collection title */
     char *organism;   /* organism name for URL, case-sensitive */
     char *server;     /* MGC server */
 };
 
 static struct mgcDb getMgcDb()
 /* get the mgc database info for the current host */
@@ -173,54 +174,54 @@
 boolean inMBLabValidDb = FALSE;
 struct sqlConnection *fconn = sqlMayConnect("hgFixed");
 if ((fconn != NULL) && sqlTableExists(fconn, "mgcMBLabValid"))
     {
     char query[64], buf[32];
     sqlSafef(query, sizeof(query), "select acc from mgcMBLabValid where acc=\"%s\"",
           acc);
     if (sqlQuickQuery(fconn, query, buf, sizeof(buf)) != NULL)
         inMBLabValidDb = TRUE;
     sqlDisconnect(&fconn);
     }
 return inMBLabValidDb;
 }
 
 static void cdnaInfoLoad(struct cloneInfo *ci, struct sqlConnection *conn)
-/* Loading clone information from gbCdnaInfo relational tables. */
+/* Loading clone information from gbCdnaInfoTable relational tables. */
 {
-// data from gbCdnaInfo and friends
+// data from gbCdnaInfoTable and friends
 char query[1024];
 sqlSafef(query, sizeof(query),
       "select "
-      "description.name, organism.name, tissue.name, library.name,"
-      "development.name, geneName.name, productName.name, mrnaClone.name,"
-      "cds.name,keyword.name,gbCdnaInfo.moddate,gbCdnaInfo.version,"
-      "gbCdnaInfo.gi"
+      "des.name, o.name, t.name, l.name,"
+      "dev.name, gene.name, p.name, m.name,"
+      "c.name,k.name,g.moddate,g.version,"
+      "g.gi"
       " from "
-      "gbCdnaInfo,description,organism,tissue,library,development,"
-      "geneName,productName,mrnaClone,cds,keyword"
+      "%s g,%s des,%s o,%s t,%s l,%s dev,"
+      "%s gene,%s p,%s m,%s c,%s k"
       " where "
       "(acc = \"%s\") and"
-      "(description = description.id) and (organism = organism.id) and"
-      "(tissue = tissue.id) and (library = library.id) and"
-      "(development = development.id) and (geneName = geneName.id) and"
-      "(productName = productName.id) and (mrnaClone = mrnaClone.id) and"
-      "(cds = cds.id) and (keyword = keyword.id)", ci->acc);
+      "(description = des.id) and (organism = o.id) and"
+      "(tissue = t.id) and (library = l.id) and"
+      "(development = dev.id) and (geneName = gene.id) and"
+      "(productName = p.id) and (mrnaClone = m.id) and"
+      "(cds = c.id) and (keyword = k.id)", gbCdnaInfoTable, descriptionTable, organismTable, tissueTable, libraryTable, developmentTable,geneNameTable, productNameTable, mrnaCloneTable, cdsTable, keywordTable, ci->acc);
 struct sqlResult *sr = sqlGetResult(conn, query);
 char **row = sqlNextRow(sr);
 if (row == NULL)
-    errAbort("can't find %s in gbCdnaInfo", ci->acc);
+    errAbort("can't find %s in %s", ci->acc, gbCdnaInfoTable);
 int i = 0;
 ci->desc = cloneString(row[i++]);
 ci->organism = cloneString(row[i++]);
 ci->tissue = cloneString(row[i++]);
 ci->library = cloneString(row[i++]);
 ci->development = cloneString(row[i++]);
 ci->geneName = cloneString(row[i++]);
 ci->productName = cloneString(row[i++]);
 ci->clone = cloneString(row[i++]);
 ci->cds = cloneString(row[i++]);
 ci->keyword = cloneString(row[i++]);
 ci->moddate = cloneString(row[i++]);
 ci->version = sqlUnsigned(row[i++]);
 ci->gi = sqlUnsigned(row[i++]);
 sqlFreeResult(&sr);
@@ -560,33 +561,33 @@
 webPrintLinkTableNewRow();
 webPrintIntCell(gmd->mrnaStart);
 webPrintIntCell(gmd->mrnaEnd);
 if (miscDiffFlds & gbMiscDiffGene)
     webPrintLinkCell(gmd->gene);
 if (miscDiffFlds & gbMiscDiffReplace)
     webPrintLinkCell(gmd->replacement);
 if (miscDiffFlds & gbMiscDiffNotes)
     webPrintLinkCell(gmd->notes);
 }
 
 static void prMiscDiffs(struct sqlConnection *conn, char *acc)
 /* print any gbMiscDiff rows for the accession */
 {
 struct gbMiscDiff *gmds = NULL, *gmd;
-if (sqlTableExists(conn, "gbMiscDiff"))
+if (sqlTableExists(conn, gbMiscDiffTable))
     gmds = sqlQueryObjs(conn, (sqlLoadFunc)gbMiscDiffLoad, sqlQueryMulti,
-                        "select * from gbMiscDiff where acc=\"%s\"", acc);
+                        "select * from %s where acc=\"%s\"", gbMiscDiffTable, acc);
 webNewSection("NCBI Clone Validation");
 if (gmds != NULL)
     {
     unsigned miscDiffFlds = getMiscDiffFields(gmds);
     webPrintLinkTableStart();
     prMiscDiffHdr(miscDiffFlds);
     for (gmd = gmds; gmd != NULL; gmd = gmd->next)
         prMiscDiff(gmd, miscDiffFlds);
     webPrintLinkTableEnd();
     }
 else
     printf("<EM>No clone discrepancies annotated</EM><BR><BR>\n");
 }
 
 static void prMethodsLink(struct sqlConnection *conn, char *track)