54be876b42771b1aea2839a533e46c073134caf1 chmalee Wed Aug 23 10:36:24 2023 -0700 Fix pgSnp items not scaling correctly when item is off the left side of the window, refs #32006 diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c index 997059d..686dd57 100644 --- src/hg/hgTracks/simpleTracks.c +++ src/hg/hgTracks/simpleTracks.c @@ -11337,32 +11337,35 @@ boolean cmpl = cartUsualBooleanDb(cart, database, COMPLEMENT_BASES_VAR, FALSE); char *display = "freq"; //cartVar? if (revCmplDisp) cmpl = !cmpl; if (vis == tvSquish || vis == tvDense || myItem->alleleCount > 2) { withIndividualLabels = TRUE; //haven't done label for this one bedDrawSimpleAt(tg, myItem, hvg, xOff, y, scale, font, color, vis); return; } /* get allele(s) to display */ char *allele[8]; char *freq[8]; int allTot = 0; -int x1 = round((double)((int)myItem->chromStart-winStart)*scale) + xOff; -int x2 = round((double)((int)myItem->chromEnd-winStart)*scale) + xOff; +int s = max(myItem->chromStart, winStart), e = min(myItem->chromEnd, winEnd); +if (s > e) + return; +int x1 = round((s-winStart)*scale) + xOff; +int x2 = round((e-winStart)*scale) + xOff; int w = x2-x1; if (w < 1) w = 1; char *nameCopy = cloneString(myItem->name); char *allFreqCopy = cloneString(myItem->alleleFreq); int cnt = chopByChar(nameCopy, '/', allele, myItem->alleleCount); if (cnt != myItem->alleleCount) errAbort("Bad allele name '%s' (%s:%d-%d): expected %d /-sep'd alleles", myItem->name, myItem->chrom, myItem->chromStart+1, myItem->chromEnd, myItem->alleleCount); int fcnt = chopByChar(allFreqCopy, ',', freq, myItem->alleleCount); if (fcnt != myItem->alleleCount && fcnt != 0) errAbort("Bad freq '%s' for '%s' (%s:%d-%d): expected %d ,-sep'd numbers", myItem->alleleFreq, myItem->name, myItem->chrom, myItem->chromStart+1, myItem->chromEnd, myItem->alleleCount);