402f419b7948c257cc171cd0f370b7a6d8237583
max
  Thu Feb 9 16:21:22 2012 -0800
changed trackDb names in t2g.c.
diff --git src/hg/hgc/t2g.c src/hg/hgc/t2g.c
index 7b96717..9379409 100644
--- src/hg/hgc/t2g.c
+++ src/hg/hgc/t2g.c
@@ -18,68 +18,68 @@
 char* t2gSecNames[] ={
       "header", "abstract",
       "intro", "methods",
       "results", "discussion",
       "conclusions", "ack",
       "refs", "unknown" };
 //
 // whether a checkbox is checked by default, have to correspond to t2gSecNames
 int t2gSecChecked[] ={
       1, 1,
       1, 1,
       1, 1,
       1, 0,
       0, 1 };
 
-char* sequenceTable;
-char* articleTable;
+char* t2gSequenceTable;
+char* t2gArticleTable;
 
 char* makeSqlMarkerList(void)
 /* return list of sections from cgi vars, format like "'abstract','header'" */
 {
 int secCount = sizeof(t2gSecNames)/sizeof(char *);
 struct slName* names = NULL;
 int i;
 for (i=0; i<secCount; i++) 
 {
     // add ' around name and add to list
     char* secName = t2gSecNames[i];
     if (cgiOptionalInt(secName, t2gSecChecked[i]))
     {
         char nameBuf[100];
         sprintf(nameBuf, "'%s'", secName);
         slAddHead(&names, slNameNew(nameBuf));
     }
 }
 
 if (names==0)
     errAbort("You need to specify at least one article section.");
 
 char* nameListString = slNameListToString(names, ',');
 slNameFree(names);
 return nameListString;
 }
 
-struct sqlResult* queryMarkerRows(struct sqlConnection* conn, char* item, int itemLimit)
+struct sqlResult* queryMarkerRows(struct sqlConnection* conn, char* markerTable, char* articleTable, char* item, int itemLimit)
 /* query marker rows from mysql, based on http parameters */
 {
 char query[4000];
 sqlUpdate(conn, "SET SESSION group_concat_max_len = 40000");
 
 char* sectionList = makeSqlMarkerList();
 
-safef(query, sizeof(query), "SELECT distinct t2gElsevierMarker.articleId, url, title, authors, citation, group_concat(snippet, section SEPARATOR ' (...) ') FROM t2gElsevierMarker JOIN t2gElsevierArticle USING (articleId) WHERE markerId='%s' GROUP by articleId LIMIT %d", item, itemLimit);
+safef(query, sizeof(query), "SELECT distinct t2gElsevierMarker.articleId, url, title, authors, citation, group_concat(snippet, section SEPARATOR ' (...) ') FROM %s JOIN %s USING (articleId) WHERE markerId='%s' GROUP by articleId LIMIT %d", markerTable, articleTable, item, itemLimit);
 //safef(query, sizeof(query), "SELECT distinct t2gElsevierMarker.articleId, url, title, authors, citation, group_concat(snippet SEPARATOR ' (...) ') FROM t2gElsevierMarker JOIN t2gElsevierArticle USING (articleId) WHERE markerId='%s' AND section IN (%s) GROUP by articleId LIMIT %d", item, sectionList, itemLimit);
 
 printf(sectionList);
 freeMem(sectionList);
 
 struct sqlResult *sr = sqlGetResult(conn, query);
 
 return sr;
 }
 
 
 void printSectionCheckboxes()
 /* show a little form with checkboxes where user can select sections they want to show */
 {
 // labels to show to user, have to correspond to t2gSecNames
@@ -123,68 +123,68 @@
 printf("</FORM><P>\n");
 }
 
 void printLimitWarning(struct sqlConnection *conn, char* item, int itemLimit)
 {
 char query[4000];
 safef(query, sizeof(query), "SELECT COUNT(*) from t2gElsevierMarker WHERE markerId='%s'", item);
 if (sqlNeedQuickNum(conn, query) > itemLimit) 
 {
     printf("<b>This marker is mentioned more than %d times</b><BR>\n", itemLimit);
     printf("The results would take too long to load in your browser and are "
     "therefore limited to %d articles.<P>\n", itemLimit);
 }
 }
 
-void printMarkerSnippets(struct sqlConnection *conn, char* item)
+void printMarkerSnippets(struct sqlConnection *conn, char* articleTable, char* markerTable, char* item)
 {
 
 /* do not show more snippets than this limit */
 int itemLimit=4000;
 
 printSectionCheckboxes();
 printLimitWarning(conn, item, itemLimit);
 
 printf("<H3>Snippets from Publications:</H3>");
 
-struct sqlResult* sr = queryMarkerRows(conn, item, itemLimit);
+struct sqlResult* sr = queryMarkerRows(conn, markerTable, articleTable, item, itemLimit);
 
 char **row;
 while ((row = sqlNextRow(sr)) != NULL)
 {
     char* articleId = row[0];
     char* url = row[1];
     char* title = row[2];
     char* authors = row[3];
     char* citation = row[4];
     char* snippets = row[5];
     printf("<A HREF=\"%s\">%s</A> ", url, title);
     printf("<SMALL>%s</SMALL>; ", authors);
     printf("<SMALL>%s</SMALL><BR>", citation);
     if (t2gDebug)
         printf("articleId=%s", articleId);
     printf("<I>%s</I><P>", snippets);
     printf("<HR>");
 }
 }
 
 char* printArticleInfo(struct sqlConnection *conn, char* item)
 /* Header with information about paper, return documentId */
 {
     char query[512];
 
-    safef(query, sizeof(query), "SELECT articleId, url, title, authors, citation, abstract FROM %s WHERE displayId='%s'", articleTable, item);
+    safef(query, sizeof(query), "SELECT articleId, url, title, authors, citation, abstract FROM %s WHERE displayId='%s'", t2gArticleTable, item);
 
     struct sqlResult *sr = sqlGetResult(conn, query);
     char **row;
     char *docId=0;
     if ((row = sqlNextRow(sr)) != NULL)
     {
         char* abstract = row[5];
         if (strlen(abstract)==0) 
             {
                 abstract = "(No abstract found for this article. Please use the link to the fulltext above.)";
             }
         docId = cloneString(row[0]);
         printf("<P>%s</P>\n", row[3]);
         printf("<A TARGET=\"_blank\" HREF=\"%s\"><B>%s</B></A>\n", row[1], row[2]);
         printf("<P style=\"width:800px; font-size:80%%\">%s</P>\n", row[4]);
@@ -260,31 +260,31 @@
     i++;
     }
 }
 }
 
 bool printSeqSection(char* docId, char* title, bool showDesc, struct sqlConnection* conn, struct hash* clickedSeqs, bool isClickedSection, bool fasta)
 /* print a table of sequences, show only sequences with IDs in hash,
  * There are two sections, respective sequences are shown depending on isClickedSection and clickedSeqs 
  *   - seqs that were clicked on (isClickedSection=True) -> show only seqs in clickedSeqs
  *   - other seqs (isClickedSection=False) -> show all other seqs
  * 
  * */
 {
     // get data from mysql
     char query[4096];
-    safef(query, sizeof(query), "SELECT fileDesc, snippet, locations, articleId,fileId, seqId, sequence FROM %s WHERE articleId='%s';", sequenceTable, docId);
+    safef(query, sizeof(query), "SELECT fileDesc, snippet, locations, articleId,fileId, seqId, sequence FROM %s WHERE articleId='%s';", t2gSequenceTable, docId);
     if (t2gDebug)
         puts(query);
     struct sqlResult *sr = sqlGetResult(conn, query);
 
     // construct title for section
     char fullTitle[5000];
     safef(fullTitle, sizeof(fullTitle), 
     "%s&nbsp;<A HREF=\"../cgi-bin/hgc?%s&o=%s&t=%s&g=%s&i=%s&fasta=%d\"><SMALL>(switch fasta format)</SMALL></A>", 
     title, cartSidUrlString(cart), cgiString("o"), cgiString("t"), cgiString("g"), cgiString("i"), 
     !fasta);
 
     webNewSection(fullTitle);
 
     if (!fasta) 
         printSeqHeaders(showDesc, isClickedSection);
@@ -444,36 +444,38 @@
 /* text2genome.org custom display */
 {
 
 int start = cgiInt("o");
 int end = cgiInt("t");
 char* trackTable = cgiString("g");
 int fasta = cgiOptionalInt("fasta", 0);
 
 t2gDebug = cgiOptionalInt("debug", 0);
 
 struct sqlConnection *conn = hAllocConn(database);
 printTrackVersion(tdb, conn, item);
 
 if (startsWith("t2gMarker", trackTable)) 
 {
+    char* markerTable = hashMustFindVal(tdb->settingsHash, "t2gMarkerTable");
+    char* articleTable = hashMustFindVal(tdb->settingsHash, "t2gArticleTable");
     printPositionAndSize(start, end, 0);
-    printMarkerSnippets(conn, item);
+    printMarkerSnippets(conn, articleTable, markerTable, item);
 }
 else 
 {
     printPositionAndSize(start, end, 1);
-    sequenceTable = hashMustFindVal(tdb->settingsHash, "sequenceTable");
-    articleTable = hashMustFindVal(tdb->settingsHash, "articleTable");
+    t2gSequenceTable = hashMustFindVal(tdb->settingsHash, "t2gSequenceTable");
+    t2gArticleTable = hashMustFindVal(tdb->settingsHash, "t2gArticleTable");
 
     char* docId = printArticleInfo(conn, item);
     if (docId!=0) 
     {
         bool showDesc; 
         showDesc = (! endsWith(trackTable, "Elsevier")); // avoid clutter: Elsevier has only main text
         printSeqInfo(conn, trackTable, docId, item, seqName, start, showDesc, fasta);
     }
 }
 
 printTrackHtml(tdb);
 hFreeConn(&conn);
 }