d3aaebb71ef2b82ece4340766c0de67541ce7362
chmalee
  Wed Jul 5 16:41:56 2023 -0700
Fix for multiple hgPcr results feature, actually use the stored primer pair in the psl qName, refs #31608

diff --git src/hg/hgTracks/cds.c src/hg/hgTracks/cds.c
index 0d6bbb6..e1d324a 100644
--- src/hg/hgTracks/cds.c
+++ src/hg/hgTracks/cds.c
@@ -962,49 +962,55 @@
 #else
 return NULL;
 #endif
 }
 
 #ifndef GBROWSE
 static struct dnaSeq *maybeGetPcrResultSeq(struct linkedFeatures *lf)
 /* Return (if possible) the primer sequences concatenated with the 
  * target sequence between where they match. */
 {
 struct dnaSeq *seq = NULL;
 char *pslFileName, *primerFileName;
 struct targetDb *target;
 if (! pcrResultParseCart(database, cart, &pslFileName, &primerFileName, &target))
     return NULL;
-char *fPrimer, *rPrimer;
-pcrResultGetPrimers(primerFileName, &fPrimer, &rPrimer);
+char *fPrimer, *rPrimer, *nonCompRPrimer;
+char *primerKey = NULL;
+if (lf->original)
+    primerKey = ((struct psl *)lf->original)->qName;
+pcrResultGetPrimers(primerFileName, &fPrimer, &rPrimer, primerKey);
 int fPrimerSize = strlen(fPrimer);
 int rPrimerSize = strlen(rPrimer);
+// we need to reverse complement the sequence for the display, but we
+// don't want to when we do the lookup in the psl file
+nonCompRPrimer = cloneString(rPrimer);
 reverseComplement(rPrimer, rPrimerSize);
-if (target != NULL)
+if (lf->name && isNotEmpty(lf->name))
     {
     struct psl *tpsl;
     char *words[3];
     int wordCount = chopByChar(cloneString(lf->extra), '|', words, ArraySize(words));
     if (wordCount != 3)
 	errAbort("maybeGetPcrResultSeq: expected 3 |-sep'd words but got '%s'",
 		 (char *)lf->extra);
     char *displayName = words[0];
     int ampStart = atoi(words[1]), ampEnd = atoi(words[2]);
     char *realName = pcrResultItemAccName(lf->name, displayName, NULL);
     /* isPcr results are so sparse that I think the performance impact 
      * of re-reading the psl file in the draw function is negligible. */
-    pcrResultGetPsl(pslFileName, target, realName, chromName, ampStart, ampEnd, &tpsl, NULL);
+    pcrResultGetPsl(pslFileName, target, realName, chromName, ampStart, ampEnd, &tpsl, NULL, fPrimer, nonCompRPrimer);
     /* Use seq+extFile if specified; otherwise just retrieve from seqFile. */
     if (isNotEmpty(target->seqTable) && isNotEmpty(target->extFileTable))
 	{
 	struct sqlConnection *conn = hAllocConn(database);
 	seq = hDnaSeqGet(database, tpsl->tName, target->seqTable,
 			 target->extFileTable);
 	hFreeConn(&conn);
 	}
     else
 	{
 	struct twoBitFile *tbf = twoBitOpen(target->seqFile);
 	seq = twoBitReadSeqFrag(tbf, tpsl->tName, 0, 0);
 	twoBitClose(&tbf);
 	}
     int start, end;