36216d451fe6fc46f9c29af334ab73788b3024f6
galt
  Wed May 28 17:30:49 2025 -0700
fixes error in hgc showAll for blat non-ct results and clicking on show full alignment. refs #32750

diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index 1fb1e6b4a3a..e9822e76dfe 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -6619,94 +6619,102 @@
  */
 {
 return ((psl->tStart == startFirst) && sameString(psl->tName, seqName)) == isClicked;
 }
 
 void printAlignmentsSimple(struct psl *pslList, int startFirst, char *hgcCommand,
                            char *tableName, char *itemIn)
 /* Print list of mRNA alignments, don't add extra textual link when
  * doesn't honor hgcCommand. */
 {
 struct psl *psl;
 int aliCount = slCount(pslList);
 boolean isClicked;
 if (pslList == NULL || tableName == NULL)
     return;
-boolean showEvery = sameString(itemIn, "PrintAllSequences");
 
+boolean showEvery = (strstr(itemIn, "PrintAllSequences") > 0);
 if (!showEvery && (aliCount > 1))
     printf("The alignment you clicked on is first in the table below.<BR>\n");
 
 printf("<PRE><TT>");
 if (startsWith("chr", pslList->tName))
     printf("BROWSER | SIZE IDENTITY CHROMOSOME  STRAND    START     END              QUERY      START  END  TOTAL\n");
 else
     printf("BROWSER | SIZE IDENTITY  SCAFFOLD   STRAND    START     END              QUERY      START  END  TOTAL\n");
 printf("-----------------------------------------------------------------------------------------------------\n");
 for (isClicked = 1; isClicked >= 0; isClicked -= 1)
     {
     for (psl = pslList; psl != NULL; psl = psl->next)
 	{
 	if (isPslToPrintByClick(psl, startFirst, isClicked))
 	    {
             char otherString[512];
             char *qName = itemIn;
-            if (sameString(itemIn, "PrintAllSequences"))
-                qName = psl->qName;
+	    if (showEvery)
+		qName = replaceChars(itemIn, "PrintAllSequences", psl->qName);
 	    safef(otherString, sizeof(otherString), "%d&aliTable=%s", psl->tStart, tableName);
             printf("<A HREF=\"%s&db=%s&position=%s%%3A%d-%d\">browser</A> | ",
                    hgTracksPathAndSettings(), database, psl->tName, psl->tStart+1, psl->tEnd);
 	    if (psl->qSize <= MAX_DISPLAY_QUERY_SEQ_SIZE) // Only anchor if small enough 
 		hgcAnchorWindow(hgcCommand, qName, psl->tStart, psl->tEnd, otherString, psl->tName);
             char *displayChromName = chromAliasGetDisplayChrom(database, cart, psl->tName);
 	    printf("%5d  %5.1f%%  %9s     %s %9d %9d  %20s %5d %5d %5d",
 		   psl->match + psl->misMatch + psl->repMatch,
 		   100.0 - pslCalcMilliBad(psl, TRUE) * 0.1,
 		   skipChr(displayChromName), psl->strand, psl->tStart + 1, psl->tEnd,
 		   psl->qName, psl->qStart+1, psl->qEnd, psl->qSize);
 	    if (psl->qSize <= MAX_DISPLAY_QUERY_SEQ_SIZE)
 	        printf("</A>");
 	    printf("\n");
+
+	    if (showEvery)
+                 freeMem(qName);
 	    }
 	}
     }
 printf("</TT></PRE>");
 }
 
 void printAlignmentsExtra(struct psl *pslList, int startFirst, char *hgcCommand, char *hgcCommandInWindow,
 		     char *tableName, char *itemIn)
 /* Print list of mRNA alignments with special "in window" alignment function. */
 {
 if (pslList == NULL || tableName == NULL)
     return;
 printAlignmentsSimple(pslList, startFirst, hgcCommand, tableName, itemIn);
 
 struct psl *psl = pslList;
 for (psl = pslList; psl != NULL; psl = psl->next)
     {
     if ( pslTrimToTargetRange(psl, winStart, winEnd) != NULL
         &&
 	!startsWith("xeno", tableName)
 	&& !(startsWith("user", tableName) && pslIsProtein(psl))
 	&& psl->tStart == startFirst
         && sameString(psl->tName, seqName)
 	)
 	{
+        boolean showEvery = (strstr(itemIn, "PrintAllSequences") > 0);
+	char *qName = itemIn;
+	if (showEvery)
+	    qName = replaceChars(itemIn, "PrintAllSequences", psl->qName);
+
         char otherString[512];
 	safef(otherString, sizeof(otherString), "%d&aliTable=%s",
 	      psl->tStart, tableName);
-	hgcAnchorSomewhere(hgcCommandInWindow, itemIn, otherString, psl->tName);
+	hgcAnchorSomewhere(hgcCommandInWindow, qName, otherString, psl->tName);
 	printf("<BR>View details of parts of alignment within browser window</A>.<BR>\n");
 	}
     }
 }
 
 void printAlignments(struct psl *pslList, int startFirst, char *hgcCommand,
 		     char *tableName, char *itemIn)
 /* Print list of mRNA alignments. */
 {
 printAlignmentsExtra(pslList, startFirst, hgcCommand, "htcCdnaAliInWindow", tableName, itemIn);
 }
 
 static struct psl *getAlignmentsTName(struct sqlConnection *conn, char *table, char *acc,
                                       char *tName)
 /* get the list of alignments for the specified acc and tName (if given). */
@@ -7406,31 +7414,35 @@
 printAlignments(pslList, start, "htcUserAli", "user", item);
 pslFreeList(&pslList);
 printf("</div>\n");
 
 
 printf("<div id=hgUsualPslShowAll style='display: none'>\n");
 // get hidden rest of alignments.
 pslxFileOpen(pslName, &qt, &tt, &lf);
 isProt = (qt == gftProt);
 while ((psl = pslNext(lf)) != NULL)
     {
     slAddHead(&pslList, psl);
     }
 slSort(&pslList, pslCmpQueryScore);
 lineFileClose(&lf);
-printAlignments(pslList, start, "htcUserAli", "user", item);
+
+char allItems[1024];
+safef(allItems, sizeof allItems, "%s %s %s", pslName, faName, "PrintAllSequences");
+
+printAlignments(pslList, start, "htcUserAli", "user", allItems);
 pslFreeList(&pslList);
 
 printf("<BR>\n");
 printf("Input Sequences:<BR>\n");
 printf("<textarea rows='8' cols='60' readonly>\n");
 struct dnaSeq *oSeq, *oSeqList = faReadAllSeq(faName, !isProt);
 for (oSeq = oSeqList; oSeq != NULL; oSeq = oSeq->next)
     {
     printf(">%s\n",oSeq->name);
     printf("%s\n",oSeq->dna);
     printf("\n");
     }
 printf("</textarea>\n");
 
 printf("</div>\n");