2af949e966b17c1cf0855c9877c1b25a81c63be5
max
  Tue Mar 27 13:57:04 2012 -0700
moving link to top of table
diff --git src/hg/hgc/pubs.c src/hg/hgc/pubs.c
index 5ff910b..5d346af 100644
--- src/hg/hgc/pubs.c
+++ src/hg/hgc/pubs.c
@@ -40,36 +40,34 @@
 if (!stringIn("sciencedirect.com", url))
     return url;
     
 // cgi param to add the "UCSC matches" sciverse application to elsevier's sciencedirect
 char* sdAddParam = "?svAppaddApp=298535"; 
 char* longUrl = catTwoStrings(url, sdAddParam);
 char* newUrl = replaceChars(longUrl, "article", "svapps");
 return newUrl;
 }
 
 static void printFilterLink(char* pslTrack, char* articleId)
 /* print a link to hgTracks with an additional cgi param to activate the single article filter */
 {
     int start = cgiInt("o");
     int end = cgiInt("t");
-    printf("&nbsp; <A HREF=\"%s&amp;db=%s&amp;position=%s%%3A%d-%d&amp;pubsFilterArticleId=%s&amp;%s=pack\">",
+    printf("<P><A HREF=\"%s&amp;db=%s&amp;position=%s%%3A%d-%d&amp;pubsFilterArticleId=%s&amp;%s=pack\">",
                       hgTracksPathAndSettings(), database, seqName, start+1, end, articleId, pslTrack);
-    char startBuf[64], endBuf[64];
-    sprintLongWithCommas(startBuf, start + 1);
-    sprintLongWithCommas(endBuf, end);
-    printf("Show these sequence matches individually on genome browser</A>");
+    printf("Show these sequence matches individually on genome browser</A> (activates track \""
+        "Individual matches for article\")</P>");
 }
 
 static char* makeSqlMarkerList(void)
 /* return list of sections from cgi vars, format like "'abstract','header'" */
 {
 int secCount = sizeof(pubsSecNames)/sizeof(char *);
 struct slName* names = NULL;
 int i;
 for (i=0; i<secCount; i++) 
 {
     // add ' around name and add to list
     char* secName = pubsSecNames[i];
     if (cgiOptionalInt(secName, pubsSecChecked[i]))
     {
         char nameBuf[100];
@@ -275,30 +273,31 @@
     char* seqIdCoordString = sqlQuickString(conn, query);
     char* seqIdCoords[1024];
     int partCount = chopString(seqIdCoordString, ",", seqIdCoords, ArraySize(seqIdCoords));
     int i;
 
     struct hash *seqIdHash = NULL;
     seqIdHash = newHash(0);
     for (i=0; i<partCount; i++) 
     {
         hashAdd(seqIdHash, seqIdCoords[i], NULL);
     }
     return seqIdHash;
 }
 
 static void printSeqHeaders(bool showDesc, bool isClickedSection) 
+/* print table and headers */
 {
     printf("<TABLE style=\"background-color: #%s\" WIDTH=\"100%%\" CELLPADDING=\"2\">\n", HG_COL_BORDER);
     printf("<TR style=\"background-color: #%s; color: #FFFFFF\">\n", HG_COL_TABLE_LABEL);
     if (showDesc)
         puts("  <TH style=\"width: 10%\">Article file</TH>\n");
     puts("  <TH style=\"width: 60%\">One row per sequence, with flanking text, sequence in bold</TH>\n");
     if (pubsDebug)
         puts("  <TH style=\"width: 30%\">Identifiers</TH>\n");
 
     if (!isClickedSection && !pubsDebug)
         puts("  <TH style=\"width: 20%\">Chained matches with this sequence</TH>\n");
     puts("</TR>\n");
 }
 
 static void printAddWbr(char* text, int distance) 
@@ -387,31 +386,39 @@
     struct sqlResult *sr = sqlGetResult(conn, query);
 
     // construct title for section
     char* otherFormat = NULL;
     if (fasta)
         otherFormat = "table";
     else
         otherFormat = "fasta";
 
     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>(%s format)</SMALL></A>", 
     title, cartSidUrlString(cart), cgiString("o"), cgiString("t"), cgiString("g"), cgiString("i"), 
     !fasta, otherFormat);
 
-    webNewSection(fullTitle);
+    webNewSection("%s", fullTitle);
+
+    if (isClickedSection)
+    {
+        printFilterLink(pslTable, articleId);
+        printf("</TD></TR>");
+    }
+    else
+        printf("</TD><TR><TD>");
 
     if (!fasta) 
         printSeqHeaders(showDesc, isClickedSection);
 
     char **row;
     bool foundSkippedRows = FALSE;
     while ((row = sqlNextRow(sr)) != NULL)
     {
         char* fileDesc = row[0];
         char* snippet  = row[1];
         char* locString= row[2];
         char* artId    = row[3];
         char* fileId   = row[4];
         char* seqId    = row[5];
         char* seq      = row[6];
@@ -462,37 +469,32 @@
                 else
                 {
                 struct slName *locs;
                 locs = slNameListFromStringArray(locArr, partCount);
                 slUniqify(&locs, slNameCmp, slNameFree);
                 printGbLinks(locs);
                 printf("<BR>");
                 printf("</TD>\n");
                 slFreeList(&locs);
                 }
 
             }
         printf("</TR>\n");
         }
 	}
-    printf("</TR>\n");
+    printf("</TR></TABLE>\n"); // finish section
 
-    if (isClickedSection)
-    {
-        printf("</TABLE></TABLE><TR><TD><P>&nbsp;");
-        printFilterLink(pslTable, articleId);
-    }
     webEndSectionTables();
     sqlFreeResult(&sr);
     return foundSkippedRows;
 }
 
 static void printSeqInfo(struct sqlConnection* conn, char* trackTable,
     char* pslTable, char* articleId, char* item, char* seqName, int start, 
     bool fileDesc, bool fasta)
     /* print sequences, split into two sections 
      * two sections: one for sequences that were clicked, one for all others*/
 {
     struct hash* clickedSeqs = getSeqIdHash(conn, trackTable, articleId, item, seqName, start);
 
     bool skippedRows;
     if (clickedSeqs)