5c9ad606d5b486c3e1360250907cae2c13869d90 braney Sun Mar 29 12:52:58 2026 -0700 Factor out common quickLift SQL load pattern into shared functions Add quickLiftResolveTable() and quickLiftSqlLoadBeds() to eliminate duplicated custom-track resolution and SQL-based quickLift loading code across bedTrack.c, simpleTracks.c, gvfTrack.c, and hgc.c. No redmine Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> diff --git src/hg/lib/quickLift.c src/hg/lib/quickLift.c index 38b0d3a16fc..0318286fb9b 100644 --- src/hg/lib/quickLift.c +++ src/hg/lib/quickLift.c @@ -10,30 +10,31 @@ #include "chain.h" #include "binRange.h" #include "basicBed.h" #include "liftOver.h" #include "hash.h" #include "bigBed.h" #include "bbiFile.h" #include "chainNetDbLoad.h" #include "hdb.h" #include "jksql.h" #include "hgConfig.h" #include "quickLift.h" #include "bigChain.h" #include "bigLink.h" #include "chromAlias.h" +#include "customTrack.h" struct bigBedInterval *quickLiftGetIntervals(char *quickLiftFile, struct bbiFile *bbi, char *chrom, int start, int end, struct hash **pChainHash) /* Return intervals from "other" species that will map to the current window. * These intervals are NOT YET MAPPED to the current assembly. */ { char *linkFileName = bigChainGetLinkFile(quickLiftFile); int maxGapBefore = 0; int maxGapAfter = 0; struct chain *chain, *chainList = chainLoadIdRangeHub(NULL, quickLiftFile, linkFileName, chrom, start, end, -1); struct lm *lm = lmInit(0); struct bigBedInterval *bbList = NULL, *bb; for(chain = chainList; chain; chain = chain->next) { @@ -469,24 +470,58 @@ previousQEnd = qEnd; previousTEnd = tEnd; // now find the mismatches in this block struct quickLiftRegions *mismatches = getMismatches(ourDb, bc->strand[0], chrom, liftDb, bc->qName, bl, bc->qSize, seqStart, seqEnd, bc->name); hrList = slCat(mismatches, hrList); } } slSort(&hrList, hrCmp); hashAdd(highLightsHash, quickLiftFile, hrList); return hrList; } +void quickLiftResolveTable(struct trackDb *tdb, char *trackTable, char **retTable, char **retLiftDb) +/* Resolve the table name and liftDb for a quickLift track. For custom tracks, + * sets *retLiftDb to CUSTOM_TRASH and *retTable to the dbTableName setting; + * otherwise sets *retTable to trackTable. Caller should have already set + * *retLiftDb to trackDbSetting(tdb, "quickLiftDb"). */ +{ +if (isCustomTrack(trackTable)) + { + *retLiftDb = CUSTOM_TRASH; + *retTable = trackDbSetting(tdb, "dbTableName"); + } +else + *retTable = trackTable; +} + +struct bed *quickLiftSqlLoadBeds(struct trackDb *tdb, char *trackTable, char *liftDb, + char *chrom, int start, int end, char *extraWhere, + ItemLoader2 loader, int numFields, boolean blocked) +/* Load items from another assembly via quickLift SQL, map them back to the reference, + * and return the lifted beds. Handles custom track table resolution internally. + * Caller provides liftDb from trackDbSetting(tdb, "quickLiftDb"). */ +{ +char *table; +quickLiftResolveTable(tdb, trackTable, &table, &liftDb); +struct hash *chainHash = newHash(8); +struct sqlConnection *conn = hAllocConn(liftDb); +char *quickLiftFile = cloneString(trackDbSetting(tdb, "quickLiftUrl")); +struct bed *bed = (struct bed *)quickLiftSql(conn, quickLiftFile, table, chrom, start, end, + NULL, extraWhere, loader, numFields, chainHash); +struct bed *liftedBeds = quickLiftBeds(bed, chainHash, blocked); +hFreeConn(&conn); +return liftedBeds; +} + char *quickLiftChainTable() /* Return the name of the quickLiftChain table. */ { static char *quickLiftChainTable = NULL; if (quickLiftChainTable == NULL) quickLiftChainTable = cfgOptionEnvDefault("QUICKLIFTCHAINNAME", quickLiftChainTableConfVariable, defaultQuickLiftChainTableName); return quickLiftChainTable; }