c86c38434ba5a31ccafd1ebdabbab00dea55fdc7 braney Sat Jun 7 11:25:01 2025 -0700 fix quickLifted bigWig on the negative strand diff --git src/hg/hgTracks/bigWigTrack.c src/hg/hgTracks/bigWigTrack.c index 70360d3d226..4e43b950aa4 100644 --- src/hg/hgTracks/bigWigTrack.c +++ src/hg/hgTracks/bigWigTrack.c @@ -14,41 +14,43 @@ #include "bbiFile.h" #include "bigWig.h" #include "errCatch.h" #include "container.h" #include "bigWarn.h" #include "mathWig.h" #include "float.h" #include "hubConnect.h" #include "chromAlias.h" #include "hgMaf.h" #include "quickLift.h" #include "chainNetDbLoad.h" #include "chain.h" #include "bigChain.h" -static void summaryToPreDraw( struct bbiFile *bbiFile, char *chrom, int start, int end, int summarySize, struct bbiSummaryElement *summary, struct preDrawElement *preDraw, int preDrawZero) +static void summaryToPreDraw( struct bbiFile *bbiFile, char *chrom, int start, int end, int summarySize, struct bbiSummaryElement *summary, struct preDrawElement *preDraw, int preDrawZero, boolean flip) /* Calculate summary and fill in predraw with results. */ { if (bigWigSummaryArrayExtended(bbiFile, chrom, start, end, summarySize, summary)) { /* Convert format to predraw */ int i; for (i=0; icount = be->validCount; pe->min = be->minVal; pe->max = be->maxVal; pe->sumData = be->sumData; pe->sumSquares = be->sumSquares; } } } struct preDrawContainer *bigWigLoadPreDraw(struct track *tg, int seqStart, int seqEnd, int width) /* Do bits that load the predraw buffer tg->preDrawContainer. */ { /* Just need to do this once... */ if (tg->preDrawContainer != NULL) return tg->preDrawContainer; @@ -83,38 +85,51 @@ for(chain = chainList; chain; chain = chain->next) { struct chain *retChain, *retChainToFree; char *chrom = chain->qName; chainSubsetOnT(chain, winStart, winEnd, &retChain, &retChainToFree); struct cBlock *cb; for(cb = retChain->blockList; cb; cb = cb->next) { // figure out where in the summary array the target coordinates put us int tSize = retChain->tEnd - retChain->tStart; int summaryOffset = (((double)cb->tStart - retChain->tStart) / tSize ) * summarySize; int summarySizeBlock = (((double)cb->tEnd - cb->tStart) / tSize ) * summarySize; // grab the data using query coordinates if (summarySizeBlock != 0) - summaryToPreDraw(bbiFile, chrom, cb->qStart, cb->qEnd, summarySizeBlock, &summary[summaryOffset], &pre->preDraw[summaryOffset], pre->preDrawZero); + { + int start = cb->qStart; + int end = cb->qEnd; + boolean flip = FALSE; + if (chain->qStrand == '-') + { + start = chain->qSize - cb->qEnd; + end = chain->qSize - cb->qStart; + flip = TRUE; + } + + summaryToPreDraw(bbiFile, chrom, start, end, summarySizeBlock, &summary[summaryOffset], &pre->preDraw[summaryOffset], pre->preDrawZero, flip); + } } } + } else { // if we're not quicklifting we can grab the whole summary from the window coordinates - summaryToPreDraw(bbiFile, chromName, winStart, winEnd, summarySize, summary, pre->preDraw, pre->preDrawZero); + summaryToPreDraw(bbiFile, chromName, winStart, winEnd, summarySize, summary, pre->preDraw, pre->preDrawZero, FALSE); } // I don't think tg->bbiFile is ever a list of more than one. Verify this bbiNext = bbiFile->next; if (bbiNext != NULL) errAbort("multiple bbiFiles found"); bigWigFileClose(&bbiFile); } tg->bbiFile = NULL; freeMem(summary); } errCatchEnd(errCatch); if (errCatch->gotError) {