5ca365292fb3146d6589273132b0c94674c51dc8
max
  Tue Mar 27 12:05:37 2012 -0700
handling case of transmapped protein alignments
diff --git src/hg/hgc/pubs.c src/hg/hgc/pubs.c
index 5dca585..c7cca09 100644
--- src/hg/hgc/pubs.c
+++ src/hg/hgc/pubs.c
@@ -324,60 +324,60 @@
     c++;
     i++;
     }
 }
 }
 
 void printHgTracksLink(char* db, char* chrom, int start, int end, char* linkText, char* optUrlStr)
 /* print link to hgTracks for db at pos */
 {
 char buf[1024];
 if (linkText==NULL) 
 {
     char startBuf[64], endBuf[64];
     sprintLongWithCommas(startBuf, start + 1);
     sprintLongWithCommas(endBuf, end);
-    safef(buf, sizeof(buf), "%s:%s-%s (%s)", seqName, startBuf, endBuf, db);
+    safef(buf, sizeof(buf), "%s:%s-%s (%s)", chrom, startBuf, endBuf, db);
     linkText = buf;
 }
 
 if (optUrlStr==NULL)
     optUrlStr = "";
     
-printf("<A HREF=\"%s&amp;db=%s&amp;position=%d-%d&amp;%s\">%s</A>\n", hgTracksPathAndSettings(), db, start, end, optUrlStr, linkText);
+printf("<A HREF=\"%s&amp;db=%s&amp;position=%s:%d-%d&amp;%s\">%s</A>\n", hgTracksPathAndSettings(), db, chrom, start, end, optUrlStr, linkText);
 }
 
 void printGbLinks(struct slName* locs) 
 /* print hash keys in format hg19/chr1:1-1000 as links */
 {
 struct slName *el;
 for (el = locs; el != NULL; el = el->next) 
 {
     char* locString = el->name;
     char* db       = cloneNextWordByDelimiter(&locString, '/');
     char* chrom    = cloneNextWordByDelimiter(&locString, ':');
     char* startStr = cloneNextWordByDelimiter(&locString, '-');
-    char* endStr   = locString;
+    char* endStr   = cloneString(locString);
 
     int start = atoi(startStr);
     int end = atoi(endStr);
     printHgTracksLink(db, chrom, start, end, NULL, NULL);
     printf("<BR>");
-    //freeMem(endStr); //XX why can't I free these?
-    //freeMem(chrom);
-    //freeMem(startStr);
-    //freeMem(db);
+    freeMem(endStr); //XX why can't I free these?
+    freeMem(chrom);
+    freeMem(startStr);
+    freeMem(db);
 }
 }
 
 static bool printSeqSection(char* articleId, char* title, bool showDesc, struct sqlConnection* conn, struct hash* clickedSeqs, bool isClickedSection, bool fasta, char* pslTable)
 /* 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 "
@@ -589,42 +589,53 @@
 }
 
 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");
+
+enum gfType qt;
+if (psl->qSize!=oSeq->size) 
+{
+    qt = gftProt;
+    // trying to correct pslMap's changes to qSize/qStarts and blockSizes
+    psl->qSize = psl->qSize/3;
+    psl->match = psl->match/3;
+    int i;
+    for (i=0; i<psl->blockCount; i++)
+    {
+        psl->qStarts[i] = psl->qStarts[i]/3; 
+        psl->blockSizes[i] = psl->blockSizes[i]/3; 
+    }
+
+}
+else
+    qt = gftDna;
+
+showSomeAlignment(psl, oSeq, qt, 0, oSeq->size, NULL, 0, 0);
 }
 
 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);
 pubsDebug        = cgiOptionalInt("debug", 0);
 
 struct sqlConnection *conn = hAllocConn(database);