eb5c9cd277c2bcd521aa461d06e9d8a32509c1d3 braney Thu Oct 9 12:17:30 2025 -0700 make it possible to use a cart variable in addition to an hg.conf variable to turn on quickLift diff --git src/hg/lib/quickLift.c src/hg/lib/quickLift.c index 42a241b0b18..38b0d3a16fc 100644 --- src/hg/lib/quickLift.c +++ src/hg/lib/quickLift.c @@ -135,39 +135,56 @@ bigBedIntervalToRow(bb, chromName, startBuf, endBuf, bedRow, ArraySize(bedRow)); struct bed *bed = bedLoadN(bedRow, bbi->definedFieldCount); char *error; if (bbi->definedFieldCount < 12) make12(bed); if ((error = remapBlockedBed(chainHash, bed, 0.0, 0.1, TRUE, TRUE, NULL, NULL)) == NULL) return bed; //else //printf("bed %s error:%s<BR>", bed->name, error); return NULL; } -unsigned quickLiftGetChain(char *fromDb, char *toDb) +char *quickLiftGetChainPath(struct cart *cart, char *fromDb, char *toDb) +/* Return the path from the quickLiftChain table for given assemblies. */ +{ +if (!quickLiftEnabled(cart)) + return 0; + +struct sqlConnection *conn = hConnectCentral(); +char query[2048]; +sqlSafef(query, sizeof(query), "select q.path from %s q where q.fromDb='%s' and q.toDb='%s'", quickLiftChainTable(), fromDb, toDb); +char *path = sqlQuickString(conn, query); + +hDisconnectCentral(&conn); + +return path; +} + +unsigned quickLiftGetChainId(struct cart *cart, char *fromDb, char *toDb) /* Return the id from the quickLiftChain table for given assemblies. */ { -if (!quickLiftEnabled()) +if (!quickLiftEnabled(cart)) return 0; unsigned ret = 0; struct sqlConnection *conn = hConnectCentral(); char query[2048]; +// this needs to use the hg.conf setting sqlSafef(query, sizeof(query), "select q.id from quickLiftChain q where q.fromDb='%s' and q.toDb='%s'", fromDb, toDb); char *geneId = sqlQuickString(conn, query); hDisconnectCentral(&conn); if (geneId) ret = atoi(geneId); return ret; } struct slList *quickLiftSql(struct sqlConnection *conn, char *quickLiftFile, char *table, char *chrom, int start, int end, char *query, char *extraWhere, ItemLoader2 loader, int numFields,struct hash *chainHash) // retrieve items for which we have a loader from a SQL database for which we have a set quickLift chains. // Save the chains we used to map the item back to the current reference. { @@ -255,34 +272,34 @@ // probably this should keep track of cases where the input does NOT have thickStart == chromStart bed->thickStart = bed->chromStart; bed->thickEnd = bed->chromEnd; } else error = remapBlockedBed(chainHash, bed, 0.0, 0.1, TRUE, TRUE, NULL, NULL); if (error == NULL) { slAddHead(&liftedBedList, bed); } } return liftedBedList; } -boolean quickLiftEnabled() +boolean quickLiftEnabled(struct cart *cart) /* Return TRUE if feature is available */ { -char *cfgEnabled = cfgOption("browser.quickLift"); +char *cfgEnabled = cartOrCfgOption(cart, "browser.quickLift"); return cfgEnabled && (sameString(cfgEnabled, "on") || sameString(cfgEnabled, "true")) ; } static int hrCmp(const void *va, const void *vb) /* Compare to sort based on chromStart. */ { const struct quickLiftRegions *a = *((struct quickLiftRegions **)va); const struct quickLiftRegions *b = *((struct quickLiftRegions **)vb); return a->chromStart - b->chromStart; } struct quickLiftRegions *getMismatches(char *ourDb, char strand, char *chrom, char *liftDb, char *liftChrom, struct bigLink *bl, int querySize, int seqStart, int seqEnd, char * chainId) // Helper function to calculate mismatches in a bigLink block { struct quickLiftRegions *hrList = NULL, *hr;