e8c22713a73f66943a295ed2b4912e6d8069e782 braney Wed Sep 10 16:54:43 2025 -0700 allow quickLiftChain and liftOverChain tables to have different names specified in hg.conf diff --git src/hg/lib/liftOver.c src/hg/lib/liftOver.c index 5222d603496..941a2afe144 100644 --- src/hg/lib/liftOver.c +++ src/hg/lib/liftOver.c @@ -6,30 +6,31 @@ #include "linefile.h" #include "hash.h" #include "options.h" #include "binRange.h" #include "chain.h" #include "chainNetDbLoad.h" #include "bed.h" #include "genePred.h" #include "sample.h" #include "hdb.h" #include "liftOverChain.h" #include "liftOver.h" #include "portable.h" #include "obscure.h" #include "net.h" +#include "hgConfig.h" struct chromMap /* Remapping information for one (old) chromosome */ { char *name; /* Chromosome name. */ struct binKeeper *bk; /* Keyed by old position, values are chains. */ }; static char otherStrand(char c) /* Swap +/- */ { if (c == '-') return '+'; else if (c == '+') @@ -1860,31 +1861,31 @@ sample->chromStart, sample->chromEnd, TRUE); free(old); } remapSample(chainHash, sample, minBlocks, fudgeThick, mapped, unmapped); sampleFree(&sample); } lineFileClose(&lf); } struct liftOverChain *liftOverChainList() /* Get list of all liftOver chains in the central database */ { struct sqlConnection *conn = hConnectCentral(); struct liftOverChain *list = NULL; char query[1024]; -sqlSafef(query, sizeof query, "select * from liftOverChain"); +sqlSafef(query, sizeof query, "select * from %s",liftOverChainTable()); list = liftOverChainLoadByQuery(conn, query); hDisconnectCentral(&conn); return list; } void filterOutMissingChains(struct liftOverChain **pChainList) /* Filter out chains that don't exist. Helps partially mirrored sites. */ { while(*pChainList) { char *newPath = hReplaceGbdb((*pChainList)->path); if (!udcExists(newPath)) { struct liftOverChain *temp = *pChainList; *pChainList = (*pChainList)->next; @@ -1911,63 +1912,73 @@ /* Get list of all liftOver chains in the central database for fromDb, * filtered to include only those chains whose liftover files exist. */ { struct liftOverChain *list = liftOverChainForDb(fromDb); filterOutMissingChains(&list); return list; } struct liftOverChain *liftOverChainForDb(char *fromDb) /* Return list of liftOverChains for this database. */ { struct sqlConnection *conn = hConnectCentral(); struct liftOverChain *list = NULL; char query[512]; if (isNotEmpty(fromDb)) - sqlSafef(query, sizeof(query), "select * from liftOverChain where fromDb='%s'", - fromDb); + sqlSafef(query, sizeof(query), "select * from %s where fromDb='%s'", + liftOverChainTable(),fromDb); else - sqlSafef(query, sizeof(query), "select * from liftOverChain"); + sqlSafef(query, sizeof(query), "select * from %s", liftOverChainTable()); list = liftOverChainLoadByQuery(conn, query); hDisconnectCentral(&conn); return list; } char *liftOverChainFile(char *fromDb, char *toDb) /* Get filename of liftOver chain */ { struct sqlConnection *conn = hConnectCentral(); struct liftOverChain *chain = NULL; char query[1024]; char *path = NULL; if (conn) { sqlSafef(query, sizeof(query), - "select * from liftOverChain where fromDb='%s' and toDb='%s'", - fromDb, toDb); + "select * from %s where fromDb='%s' and toDb='%s'", + liftOverChainTable(), fromDb, toDb); chain = liftOverChainLoadByQuery(conn, query); if (chain != NULL) { path = hReplaceGbdbMustDownload(chain->path); liftOverChainFree(&chain); } hDisconnectCentral(&conn); } return path; } char *liftOverErrHelp() /* Help message explaining liftOver failures */ { return "Deleted in new:\n" " Sequence intersects no chains\n" "Partially deleted in new:\n" " Sequence insufficiently intersects one chain\n" "Split in new:\n" " Sequence insufficiently intersects multiple chains\n" "Duplicated in new:\n" " Sequence sufficiently intersects multiple chains\n" "Boundary problem:\n" " Missing start or end base in an exon\n"; } + +char *liftOverChainTable() +/* Return the name of the liftOverChain table. */ +{ +static char *liftOverChainTable = NULL; +if (liftOverChainTable == NULL) + liftOverChainTable = cfgOptionEnvDefault("LIFTOVERCHAINNAME", + liftOverChainTableConfVariable, defaultLiftOverChainTableName); +return liftOverChainTable; +}