7120a354ec4870b3bc2112c384bdb0af837ed44e
braney
  Thu Apr 23 14:12:36 2026 -0700
hgc: make quickLifted NCBI RefSeq / UCSC RefSeq click details work. refs #36125

- trackHub.c isVetted(): accept refGene, ncbiRefSeq* subtracks, and ncbiOrtho
so the generated quickLift hub.txt doesn't emit 'avoidHandler on' for them.
Without this, hgc skips findNameBasedHandler and the detail click falls
through to genericClickHandler, showing none of the rich RefSeq fields.
- hgc.c findNameBasedHandler: when the tdb has 'quickLifted on', strip the
hub_NNN_ prefix from the dispatch table before comparisons so refGene /
ncbiRefSeq* match their native handlers.
- doNcbiRefSeq / doRefGene: route hAllocConn to quickLiftDb (source), use
trackHubSkipHubName for track/table name comparisons, and pass srcDb into
replaceInUrl, hTableExists, AceView / MGIid / jaxOrtholog / hg-prefix
checks -- otherwise these paths errAborted with "Unknown database
hub_NNN_<db>" on a quickLifted click.
- printRefSeqInfo / prRefGeneInfo / gbCdnaGetVersion: use sqlGetDatabase(conn)
rather than the global `database` for host-db checks.
- Predicted Protein / Predicted mRNA links for quickLifted tracks now point
at htcTranslatedPredMRna / htcGeneMrna so the sequences come from the
destination genome at the lifted exon coordinates, rather than the
NCBI-authored refPep / seqNcbiRefSeq extFiles on the source. Native
behavior is unchanged.
- showGenePos: fetch via quickLiftSql + calcLiftOverGenePreds when the track
is quickLifted so the Position line is in destination coordinates. The
swapped chainHash comes from the track's quickLiftUrl bigChain, matching
the pattern getGenePredForPositionSql already uses.
- Suppress the mRNA/Genomic Alignments block and its trailing <hr> for
quickLifted refGene / ncbiRefSeq* clicks. The PSLs come back in source
coords and the htcCdnaAli links don't line up with the destination window.
- getAlignmentsTName: use sqlGetDatabase(conn) rather than global `database`
so split-table resolution looks up the right db.
- printGeneCards: take a db argument; callers pass srcDb so the GeneCards
link renders on quickLifted pages (the "startsWith hg" check was matching
hub_NNN_hs1 as false).
- geneReviewsClick.c prGRShortRefGene: take a struct sqlConnection * rather
than opening its own on `database` (hub_NNN_hs1 -> Unknown database abort).
Callers in prRefGeneInfo and doOmimGene2 pass their existing source-db
conn, so the Related GeneReviews line now shows on both native and
quickLifted refGene pages.

Verified end-to-end on hgwdev-braney with hg38 -> hs1 quickLift of the
refSeqComposite: ncbiRefSeqCurated and refGene clicks on SHH now render
the full doNcbiRefSeq / doRefGene details (RefSeq / Status / Description
/ Synonyms / OMIM / Protein / HGNC / Entrez Gene / GeneCards / AceView /
Summary / Position / Gene Symbol); Predicted mRNA and Predicted Protein
links return destination-derived sequences; Genomic Sequence reaches the
Get-DNA-in-window page; Ctrl/Cmd+drag zoom no longer ends up with an
HTML error page inside the zoom dialog. Non-quickLifted hg38 refSeq
details are unchanged (alignments still shown, GeneReviews still present).

The duplicate-subtracks symptom from the ticket's step (i) is not
addressed here -- it's an architectural consequence of the shared
`refSeqComposite` cart key applying to both the destination's native
composite and the quickLift hub's composite, and needs cart-scoping
work in quickLift v2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

diff --git src/hg/hgc/geneReviewsClick.c src/hg/hgc/geneReviewsClick.c
index cb0994f330f..658d69bdd6a 100644
--- src/hg/hgc/geneReviewsClick.c
+++ src/hg/hgc/geneReviewsClick.c
@@ -1,20 +1,21 @@
 /* geneReviewsClick - hgc code to display geneReviews track item detail page */
 
 /* Copyright (C) 2014 The Regents of the University of California 
  * See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */
 #include "common.h"
+#include "trackHub.h"
 #include "hgc.h"
 #include "geneReviewsClick.h"
 
 void doGeneReviews(struct trackDb *tdb, char *itemName)
 /* generate the detail page for geneReviews */
 {
 genericHeader(tdb, itemName);
 
 struct sqlConnection *conn = hAllocConn(database);
 int start = cartInt(cart, "o");
 int end = cartInt(cart, "t");
 printf("<B>Link to Gene Reviews:</B> "
        "<a href='https://www.ncbi.nlm.nih.gov/books/NBK1116/?term=%s' target=_blank>%s</a><BR>\n",
          itemName, itemName); printPos(seqName, start, end, NULL, TRUE, itemName);
 prGeneReviews(conn, itemName);
@@ -64,34 +65,35 @@
         printf("<A HREF=\"https://www.ncbi.nlm.nih.gov/books/%s\" TARGET=_blank><B>%s</B></A>", NBKid, grShort);
         if (strlen(grShort) <= 20) {
           for (i = 0; i <  20-strlen(grShort); i ++ )
              {
                 printf("%s", " " );
              }
            }
        printf("%s%s<BR>", spacer, grTitle);
 
 //        printf("<A HREF=\"https://www.ncbi.nlm.nih.gov/books/%s\" TARGET=_blank><B>%s</B></A>%s%s<BR>", NBKid, NBKid, spacer, grTitle);
     }  /* end while */
  printf("</TT></PRE>");
  sqlFreeResult(&sr);
 } /* end of prGeneReviews */
 
-void prGRShortRefGene(char *itemName)
-/* print GeneReviews short label associated to this refGene item */
+void prGRShortRefGene(struct sqlConnection *conn, char *itemName)
+/* print GeneReviews short label associated to this refGene item.
+ * Caller supplies the connection, so quickLifted callers can point us at
+ * the source assembly (geneReviewsDetail lives on hg38/hg19). */
 {
-struct sqlConnection *conn  = hAllocConn(database);
 struct sqlResult *sr;
 char **row;
 char query[512];
 boolean firstTime = TRUE;
 
 if (!sqlTableExists(conn, "geneReviewsDetail")) return;
 
 sqlSafef(query, sizeof(query), "select grShort, NBKid, grTitle from geneReviewsDetail where geneSymbol='%s'", itemName);
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
         char *grShort = *row++;
 	char *NBKid = *row++;
         char *grTitle = *row++;