8c8823d9a87b6046094577a808dda4ed4172b416 braney Thu Apr 23 11:09:48 2026 -0700 Make quickLifted GENCODE tracks usable: click details, position links, coloring. refs #36059 - Re-vet wgEncodeGencode* in trackHub.c:isVetted() so the quickLift hub no longer emits `avoidHandler on` for GENCODE children. Without this, hgc bypasses findNameBasedHandler and doGencodeGene is never reached, so the details page falls through to the generic showGenePos output. - In gencodeClick.c doGencodeGene/helpers, use quickLiftDb for the MySQL connection (the attrs/tag/pubMed/refSeq/uniProt tables live in the source assembly), use trackHubSkipHubName(tdb->track) for the genePred table name and the Basic/Comp/PseudoGene/PolyA prefix dispatch checks, and teach isGrcHuman/isGrcH37Native to consult the source db — otherwise the page errAborted with "BUG: gencodeClick on wrong database: hub_NNNNN_hs1". - Lift the Position values (transcript + gene bounds, 2-way pseudo, PolyA) through the quickLift chain before printing, so the details page shows destination-assembly coords and the Position link lands at a window that actually contains the gene. - htcDnaNearGene (hgc.c): when quickLifted, lift seqName/winStart/winEnd back to source coords before hgSeqItemsInRange. The prior code pointed the query at the source-assembly table but still passed the destination window, so the "Genomic Sequence from assembly" flow returned "No results returned from query." No longer reachable from the GENCODE details page (doGencodeGene writes its own Sequences table) but still hit by other quickLifted genePred tracks. - simpleTracks.c genePredItemClassColor: the hTableExists() guard was checking `database` (the destination hub db like hub_NNNNN_hs1) even though the MySQL conn was already routed to liftDb; the lookup was skipped and every item fell back to tg->ixColor, rendering all black. Check `db` instead so the gClass_* palette (coding / nonCoding / pseudo / problem) is applied. Verified end-to-end on hgwdev-braney: Gerardo's SHH test case (ENST00000297261.7) and Basic/Comp/PseudoGene/PolyA subtracks; no regression on the non-quickLifted hg38 click. diff --git src/hg/hgc/gencodeClick.c src/hg/hgc/gencodeClick.c index bb7cdb480ac..b1bb04279ab 100644 --- src/hg/hgc/gencodeClick.c +++ src/hg/hgc/gencodeClick.c @@ -1,21 +1,23 @@ /* gencodeClick - click handling for GENCODE tracks */ /* 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 "hgc.h" +#include "trackHub.h" +#include "quickLift.h" #include "gencodeClick.h" #include "gencodeTracksCommon.h" #include "ccdsClick.h" #include "genePred.h" #include "genePredReader.h" #include "ensFace.h" #include "htmshell.h" #include "jksql.h" #include "regexHelper.h" #include "encode/wgEncodeGencodeAttrs.h" #include "encode/wgEncodeGencodeGeneSource.h" #include "encode/wgEncodeGencodePdb.h" #include "encode/wgEncodeGencodePubMed.h" #include "encode/wgEncodeGencodeRefSeq.h" #include "encode/wgEncodeGencodeTag.h" @@ -55,60 +57,77 @@ static char *gencodeTagsUrl = "http://www.gencodegenes.org/pages/tags.html"; static char *yalePseudoUrl = "http://tables.pseudogene.org/%s"; static char *apprisHomeUrl = "https://appris.bioinfo.cnio.es/#/"; static char *apprisGeneUrl = "https://appris.bioinfo.cnio.es/#/database/id/%s/%s?sc=ensembl"; // species-specific static char *hgncByIdUrl = "https://www.genenames.org/data/gene-symbol-report/#!/hgnc_id/%s"; static char *hgncBySymUrl = " https://www.genenames.org/data/gene-symbol-report/#!/symbol/%s"; static char *geneCardsUrl = "http://www.genecards.org/cgi-bin/carddisp.pl?gene=%s"; static char *mgiBySymUrl = "http://www.informatics.jax.org/quicksearch/summary?queryType=exactPhrase&query=%s"; static char *mgiByIdUrl = "http://www.informatics.jax.org/accession/%s"; static char* UNKNOWN = "unknown"; -static boolean isGrcHuman() -/* is this a GRC human assembly? */ +static char *gencodeSourceDb(struct trackDb *tdb) +/* return the assembly the gencode tables actually live in: the quickLiftDb + * when the track is quickLifted, otherwise the current database. */ { -//bool result = FALSE; -//if (startsWith("hg", database)) -// result = TRUE; -//else if (!startsWith("mm", database)) -// warn("BUG: gencodeClick on wrong database: %s", database); -//return result; +char *liftDb = trackDbSetting(tdb, "quickLiftDb"); +return (liftDb != NULL) ? liftDb : database; +} -if (startsWith("hg", database)) +static void liftAnnoPos(struct trackDb *tdb, char *chrom, int start, int end, + char **retChrom, int *retStart, int *retEnd) +/* If the tdb is quickLifted, translate chrom:start-end from the source + * assembly to the destination assembly the user is viewing. Otherwise + * return the input unchanged. Falls back to input on lift failure. */ +{ +*retChrom = chrom; +*retStart = start; +*retEnd = end; +char *liftDb = trackDbSetting(tdb, "quickLiftDb"); +if (liftDb != NULL) + quickLiftLiftPos(liftDb, trackHubSkipHubName(database), + chrom, start, end, retChrom, retStart, retEnd); +} + +static boolean isGrcHuman(struct trackDb *tdb) +/* is this a GRC human assembly? */ +{ +char *db = gencodeSourceDb(tdb); +if (startsWith("hg", db)) return TRUE; -else if (startsWith("mm", database)) +else if (startsWith("mm", db)) return FALSE; else - errAbort("BUG: gencodeClick on wrong database: %s", database); + errAbort("BUG: gencodeClick on wrong database: %s", db); return FALSE; } static bool haveGencodeTable(struct sqlConnection *conn, struct trackDb *tdb, char *tableBase) /* determine if a gencode table exists; it might be option or not in older releases */ { return sqlTableExists(conn, gencodeGetTableName(tdb, tableBase)); } static boolean isGrcH37Native(struct trackDb *tdb) /* Is this GENCODE GRCh37 native build, which requires a different Ensembl site. */ { // check for non-lifted GENCODE on GRCh37/hg19 -if (sameString(database, "hg19")) +if (sameString(gencodeSourceDb(tdb), "hg19")) return stringIn("lift37", gencodeGetVersion(tdb)) == NULL; else return FALSE; } static boolean isRealGeneSymbol(char* geneName, boolean haveGeneSymbolSource, struct wgEncodeGencodeGeneSymbol *geneSymbolSource) /* Attempt to determine if this is a gene symbol assigned by HGNC/MGI or a * generate one. newer versions of GENCODE have wgEncodeGencodeGeneSymbol, * which has the definitions. With older version of GENCODE guess a guess * is make by trying to match older clone-based names ones. */ { if (haveGeneSymbolSource) { @@ -139,60 +158,60 @@ } static bool isProteinCodingTrans(struct wgEncodeGencodeAttrs *transAttrs) /* is a transcript protein coding? */ { return sameString(transAttrs->transcriptClass, "coding"); } static struct genePred *transAnnoLoad(struct sqlConnection *conn, struct trackDb *tdb, char *gencodeId) /* load the gencode annotations and sort the one corresponding to the one that was clicked on is * first. Should only have one or two. */ { // must check chrom due to PAR char where[256]; sqlSafef(where, sizeof(where), "(chrom = \"%s\") and (name = \"%s\")", seqName, gencodeId); -struct genePred *transAnno = genePredReaderLoadQuery(conn, tdb->track, where); +struct genePred *transAnno = genePredReaderLoadQuery(conn, trackHubSkipHubName(tdb->track), where); slSort(&transAnno, transAnnoCmp); return transAnno; } static struct wgEncodeGencodeAttrs *transAttrsLoad(struct trackDb *tdb, struct sqlConnection *conn, char *gencodeId) /* load the gencode attributes */ { char query[1024]; sqlSafef(query, sizeof(query), "select * from %s where transcriptId = \"%s\"", gencodeGetTableName(tdb, "wgEncodeGencodeAttrs"), gencodeId); struct sqlResult *sr = sqlGetResult(conn, query); char **row = sqlNextRow(sr); if (row == NULL) errAbort("gencode transcript %s not found in %s", gencodeId, gencodeGetTableName(tdb, "wgEncodeGencodeAttrs")); // older version don't have proteinId column. struct wgEncodeGencodeAttrs *transAttrs = wgEncodeGencodeAttrsLoad(row, sqlCountColumns(sr)); sqlFreeResult(&sr); return transAttrs; } static void getGeneBounds(struct trackDb *tdb, struct sqlConnection *conn, struct genePred *transAnno, int *geneChromStart, int *geneChromEnd) /* find bounds for the gene */ { // must check chrom due to PAR char where[256]; sqlSafef(where, sizeof(where), "(chrom = \"%s\") and (name2 = \"%s\")", seqName, transAnno->name2); -struct genePred *geneAnnos = genePredReaderLoadQuery(conn, tdb->track, where); +struct genePred *geneAnnos = genePredReaderLoadQuery(conn, trackHubSkipHubName(tdb->track), where); struct genePred *geneAnno; *geneChromStart = transAnno->txStart; *geneChromEnd = transAnno->txEnd; for (geneAnno = geneAnnos; geneAnno != NULL; geneAnno = geneAnno->next) { *geneChromStart = min(*geneChromStart, geneAnno->txStart); *geneChromEnd = max(*geneChromEnd, geneAnno->txEnd); } genePredFreeList(&geneAnnos); } static void *metaDataLoad(struct trackDb *tdb, struct sqlConnection *conn, char *gencodeId, char *tableBase, char *keyCol, unsigned queryOpts, sqlLoadFunc loadFunc) /* load autoSql objects for gencode meta data. */ { return sqlQueryObjs(conn, loadFunc, queryOpts, "select * from %s where %s = \"%s\"", @@ -470,54 +489,60 @@ printf("