c90837e6e7b85301490c0f89bfc0ba83255dc0df
max
  Mon Mar 26 15:25:40 2012 -0700
adding elsevier outlinks for sciverse app to hgc publications page
diff --git src/hg/hgc/pubs.c src/hg/hgc/pubs.c
index aea3be7..5dca585 100644
--- src/hg/hgc/pubs.c
+++ src/hg/hgc/pubs.c
@@ -22,30 +22,43 @@
       "intro", "methods",
       "results", "discussion",
       "conclusions", "ack",
       "refs", "unknown" };
 //
 // whether a checkbox is checked by default, have to correspond to pubsSecNames
 static int pubsSecChecked[] ={
       1, 1,
       1, 1,
       1, 1,
       1, 0,
       0, 1 };
 
 static char* pubsSequenceTable;
 
+static char* mangleUrl(char* url) 
+/* add publisher specific parameters to url and return new url*/
+{
+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\">",
                       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>");
 }
 
 static char* makeSqlMarkerList(void)
 /* return list of sections from cgi vars, format like "'abstract','header'" */
@@ -168,34 +181,32 @@
 printLimitWarning(conn, markerTable, item, itemLimit, sectionList);
 
 printf("<H3>Snippets from Publications:</H3>");
 struct sqlResult* sr = queryMarkerRows(conn, markerTable, articleTable, item, itemLimit, sectionList);
 
 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* pmid      = row[5];
     char* snippets  = row[6];
-    char* addParam  = "";
-    if (strstrNoCase(url, "sciencedirect.com"))
-        addParam = "?svAppaddApp=298535"; // add the "UCSC matches" sciverse application to article view
-    printf("<A HREF=\"%s%s\">%s</A> ", url, addParam, title);
+    url = mangleUrl(url);
+    printf("<A HREF=\"%s\">%s</A> ", url, title);
     printf("<SMALL>%s</SMALL>; ", authors);
     printf("<SMALL>%s ", citation);
     if (!isEmpty(pmid) && strcmp(pmid, "0")!=0 )
         printf(", <A HREF=\"http://www.ncbi.nlm.nih.gov/pubmed/%s\">PMID%s</A>\n", pmid, pmid);
     printf("</SMALL><BR>\n");
     if (pubsDebug)
         printf("articleId=%s", articleId);
     printf("<I>%s</I><P>", snippets);
     printf("<HR>");
 }
 
 freeMem(sectionList);
 sqlFreeResult(&sr);
 }
 
@@ -212,30 +223,32 @@
     if ((row = sqlNextRow(sr)) == NULL)
     {
         printf("Could not resolve articleId %s, this is an internal error.\n", item);
         printf("Please send an email to max@soe.ucsc.edu\n");
         sqlFreeResult(&sr);
         return NULL;
     }
 
     articleId = cloneString(row[0]);
     char* url      = row[1];
     char* title    = row[2];
     char* authors  = row[3];
     char* cit      = row[4];
     char* abstract = row[5];
     char* pmid     = row[6];
+
+    url = mangleUrl(url);
     if (strlen(abstract)==0) 
             abstract = "(No abstract available for this article. "
                 "Please follow the link to the fulltext above.)";
 
     printf("<P>%s</P>\n", authors);
     printf("<A TARGET=\"_blank\" HREF=\"%s\"><B>%s</B></A>\n", url, title);
     printf("<P style=\"width:800px; font-size:80%%\">%s", cit);
     if (strlen(pmid)!=0 && strcmp(pmid, "0"))
         printf(", <A HREF=\"http://www.ncbi.nlm.nih.gov/pubmed/%s\">PMID%s</A>\n", pmid, pmid);
     printf("</P>\n");
     printf("<P style=\"width:800px; font-size:100%%\">%s</P>\n", abstract);
 
     sqlFreeResult(&sr);
     return articleId;
 }
@@ -559,46 +572,55 @@
 char query[512];
 struct sqlResult *sr;
 char **row;
 bioSeq *seq = NULL;
 safef(query, sizeof(query), 
     "select sequence from %s where annotId = '%s'", table, id);
 sr = sqlGetResult(conn, query);
 if ((row = sqlNextRow(sr)) != NULL)
     {
     AllocVar(seq);
     seq->name = cloneString(id);
     seq->dna = cloneString(row[0]);
     seq->size = strlen(seq->dna);
     }
 sqlFreeResult(&sr);
+
 return seq;
 }
 
 void pubsAli(struct sqlConnection *conn, char *pslTable, char *seqTable, char *item)
 /* this is just a ripoff from htcCdnaAli, similar to markd's transMapAli */
 {
 bioSeq *oSeq = NULL;
 writeFramesetType();
 puts("<HTML>");
 printf("<HEAD>\n<TITLE>Literature Sequence vs Genomic</TITLE>\n</HEAD>\n\n");
 
 struct psl *psl = getAlignments(conn, pslTable, item);
 if (psl == NULL)
     errAbort("Couldn't find alignment at %s:%s", pslTable, item);
 
 oSeq = getSeq(conn, seqTable, item);
+if (oSeq->size != psl->qSize) 
+{
+    //errAbort("prot alignments not supported yet");
+    //oSeq -> size = 3*oSeq -> size;
+    errAbort("prot alignments not supported yet %s", oSeq->dna);
+    oSeq = translateSeq(oSeq, 0, FALSE);
+    errAbort("prot alignments not supported yet %s", oSeq->dna);
+}
 if (oSeq == NULL)  
     errAbort("%s is in pslTable but not in sequence table. Internal error.", item);
 showSomeAlignment(psl, oSeq, gftDna, 0, oSeq->size, NULL, 0, 0);
 printf("hihi");
 }
 
 void doPubsDetails(struct trackDb *tdb, char *item)
 /* publications custom display */
 {
 
 int start        = cgiInt("o");
 int end          = cgiOptionalInt("t", 0);
 char* trackTable = cgiString("g");
 char* aliTable   = cgiOptionalString("aliTable");
 int fasta        = cgiOptionalInt("fasta", 0);