fabf13fff3e3abaf7ef83c69a8c60d0142c288a1
braney
  Fri May 15 12:05:59 2026 -0700
fix two remaining quickLift issues on UCSC RefSeq item detail page: CCDS link routes to source assembly (with coords lifted back) so the ccdsGene handler doesn't try to open the hub-virtual db, and Get Genomic Sequence Near Gene now reads sequence from the destination assembly at the lifted exon coordinates refs #36125

diff --git src/hg/hgc/ccdsClick.c src/hg/hgc/ccdsClick.c
index 07572f58d78..9eabd5ca062 100644
--- src/hg/hgc/ccdsClick.c
+++ src/hg/hgc/ccdsClick.c
@@ -3,65 +3,78 @@
 /* Copyright (C) 2013 The Regents of the University of California 
  * See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */
 #include "common.h"
 #include "hgc.h"
 #include "ccdsClick.h"
 #include "ccdsInfo.h"
 #include "ccdsNotes.h"
 #include "ccdsGeneMap.h"
 #include "geneSimilarities.h"
 #include "genbank.h"
 #include "genePred.h"
 #include "genePredReader.h"
 #include "ensFace.h"
 #include "mgcClick.h"
 #include "htmshell.h"
+#include "quickLift.h"
+#include "trackHub.h"
 
 static struct ccdsInfo *getCcdsInfoForSrcDb(struct sqlConnection *conn, char *acc)
 /* Get a ccdsInfo object for a RefSeq, ensembl, or vega gene, if it
  * exists, otherwise return NULL */
 {
 if (sqlTableExists(conn, "ccdsInfo"))
     return ccdsInfoSelectByMrna(conn, acc);
 else
     return NULL;
 }
 
 void printCcdsExtUrl(char *ccdsId)
 /* Print out URL to link to CCDS database at NCBI */
 {
 printf("https://www.ncbi.nlm.nih.gov/CCDS/CcdsBrowse.cgi?REQUEST=CCDS&BUILDS=ALLBUILDS&DATA=%s", ccdsId);
 }
 
-static void printCcdsUrlForSrcDb(struct sqlConnection *conn, struct ccdsInfo *ccdsInfo)
+static void printCcdsUrlForSrcDb(struct trackDb *tdb, struct ccdsInfo *ccdsInfo)
 /* Print out CCDS hgc URL for a refseq, ensembl, or vega gene, if it
  * exists.  */
 {
+// When the gene track is quickLifted, the CCDS tables live with the
+// source assembly, so route the click to liftDb and lift the window
+// coords back to source space.
+char *liftDb = (tdb != NULL) ? trackDbSetting(tdb, "quickLiftDb") : NULL;
+char *urlDb = (liftDb != NULL) ? liftDb : database;
+char *urlChrom = seqName;
+int urlStart = winStart, urlEnd = winEnd;
+if (liftDb != NULL)
+    quickLiftLiftPos(trackHubSkipHubName(database), liftDb,
+                     seqName, winStart, winEnd,
+                     &urlChrom, &urlStart, &urlEnd);
 printf("../cgi-bin/hgc?%s&g=ccdsGene&i=%s&c=%s&o=%d&l=%d&r=%d&db=%s",
-       cartSidUrlString(cart), ccdsInfo->ccds, seqName, 
-       winStart, winStart, winEnd, database);
+       cartSidUrlString(cart), ccdsInfo->ccds, urlChrom,
+       urlStart, urlStart, urlEnd, urlDb);
 }
 
-void printCcdsForSrcDb(struct sqlConnection *conn, char *acc)
+void printCcdsForSrcDb(struct sqlConnection *conn, struct trackDb *tdb, char *acc)
 /* Print out CCDS hgc link for a refseq, ensembl, or vega gene, if it
  * exists.  */
 {
 struct ccdsInfo *ccdsInfo = getCcdsInfoForSrcDb(conn, acc);;
 if (ccdsInfo != NULL)
     {
     printf("<B>CCDS:</B> <A href=\"");
-    printCcdsUrlForSrcDb(conn, ccdsInfo);
+    printCcdsUrlForSrcDb(tdb, ccdsInfo);
     printf("\">%s</A><BR>", ccdsInfo->ccds);
     }
 }
 
 struct ccdsGeneMap *getCcdsGenesForMappedGene(struct sqlConnection *conn, char *acc,
                                               char *mapTable)
 /* get a list of ccds genes associated with a current and window from a
  * mapping table, or NULL */
 {
 struct ccdsGeneMap *ccdsGenes = NULL;
 if (sqlTableExists(conn, mapTable) && sqlTableExists(conn, "ccdsInfo"))
     ccdsGenes = ccdsGeneMapSelectByGeneOver(conn, mapTable, acc, seqName,
                                        winStart, winEnd, 0.0);
 slSort(&ccdsGenes, ccdsGeneMapCcdsIdCmp);
 return ccdsGenes;