e323d595c241d03570d380d8c60de60e99c1c4ec braney Fri Mar 21 12:36:21 2025 -0700 add support for bigDbSnp to quicklift diff --git src/hg/hgc/bigDbSnpClick.c src/hg/hgc/bigDbSnpClick.c index 48004243ffa..ae055a0dca5 100644 --- src/hg/hgc/bigDbSnpClick.c +++ src/hg/hgc/bigDbSnpClick.c @@ -1,28 +1,29 @@ /* Show details for bigDbSnp track items. */ /* Copyright (C) 2019 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 "bigDbSnp.h" #include "dbSnpDetails.h" #include "bPlusTree.h" #include "htslib/bgzf.h" #include "soTerm.h" #include "chromAlias.h" +#include "quickLift.h" static struct dbSnpDetails *getDetails(struct bigDbSnp *bds, char *detailsFileOrUrl) /* Seek to the offset for this variant in detailsFileOrUrl, read the line and load as * struct dbSnpDetails. */ { bits64 offset = bds->_dataOffset; bits64 len = bds->_dataLen; char *line = readOneLineMaybeBgzip(detailsFileOrUrl, offset, len); // Newline must be trimmed or else it messes up parsing of final column if empty! if (line[len-1] == '\n') line[len-1] = '\0'; char *row[DBSNPDETAILS_NUM_COLS+1]; int wordCount = chopTabs(line, row); if (wordCount != DBSNPDETAILS_NUM_COLS) errAbort("dbSnpDetails: expected %d tab-separated words at offset %Ld in %s, got %d", @@ -369,31 +370,37 @@ int end = cartInt(cart, "t"); char *fileOrUrl = hReplaceGbdb(trackDbSetting(tdb, "bigDataUrl")); if (isEmpty(fileOrUrl)) errAbort("bigDbSnpClick: trackDb is missing bigDataUrl setting"); struct bbiFile *bbi = bigBedFileOpenAlias(fileOrUrl, chromAliasFindAliases); boolean found = FALSE; char *chrom = cartString(cart, "c"); int ivStart = start, ivEnd = end; if (start == end) { // item is an insertion; expand the search range from 0 bases to 2 so we catch it: ivStart = max(0, start-1); ivEnd++; } struct lm *lm = lmInit(0); -struct bigBedInterval *bbList = bigBedIntervalQuery(bbi, chrom, ivStart, ivEnd, 0, lm); +char *quickLiftFile = cloneString(trackDbSetting(tdb, "quickLiftUrl")); +struct hash *chainHash = NULL; +struct bigBedInterval *bbList = NULL; +if (quickLiftFile) + bbList = quickLiftGetIntervals(quickLiftFile, bbi, chrom, ivStart, ivEnd, &chainHash); +else + bbList = bigBedIntervalQuery(bbi, chrom, ivStart, ivEnd, 0, lm); struct bigBedInterval *bb; for (bb = bbList; bb != NULL; bb = bb->next) { if (!startsWithWord(rsId, bb->rest)) continue; found = TRUE; char startBuf[16], endBuf[16]; char *row[BIGDBSNP_NUM_COLS]; int bbFieldCount = bigBedIntervalToRow(bb, chrom, startBuf, endBuf, row, ArraySize(row)); if (bbFieldCount != BIGDBSNP_NUM_COLS) errAbort("bigDbSnpClick: expected %d columns but got %d", BIGDBSNP_NUM_COLS, bbFieldCount); struct bigDbSnp *bds = bigDbSnpLoad(row); struct dbSnpDetails *details = NULL; struct slPair *detailsUrls = parseDetailsTablUrls(tdb); if (detailsUrls)