9dbc95fd97afbb7a278452fb660d7ddc1a28d9c7 braney Mon Nov 24 09:55:38 2025 -0800 fix maf frames caching bug #36691 diff --git src/hg/hgTracks/wigMafTrack.c src/hg/hgTracks/wigMafTrack.c index c1b4933b210..324e0acb7e0 100644 --- src/hg/hgTracks/wigMafTrack.c +++ src/hg/hgTracks/wigMafTrack.c @@ -1977,30 +1977,38 @@ for (bb = bbList; bb != NULL; bb = bb->next) { bigBedIntervalToRow(bb, chromName, startBuf, endBuf, bedRow, ArraySize(bedRow)); if (sameString(bedRow[3], component)) { mf = mafFramesLoad( bedRow ); slAddHead(&mfList, mf); } } bbiFileClose(&bbi); slReverse(&mfList); return mfList; } +static char * extraPrevious = NULL; + +static void resetCache() +// reset the frames cache +{ +extraPrevious = NULL; +} + static int wigMafDrawBases(struct track *track, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, MgFont *font, Color color, enum trackVisibility vis, struct wigMafItem *miList) /* Draw base-by-base view, return new Y offset. */ { struct wigMafItem *mi; struct mafAli *mafList, *maf, *sub; struct mafComp *mc, *mcMaster; int lineCount = slCount(miList); char **lines = NULL, *selfLine; int *insertCounts; int i, x = xOff, y = yOff; struct dnaSeq *seq = NULL; struct hash *miHash = newHash(9); @@ -2424,31 +2432,30 @@ complement(line, strlen(line)); } if (genomeIsRna) toRna(line); /* draw sequence letters for alignment */ hvGfxSetClip(hvg, x, y-1, width, mi->height); /* having these static here will allow the option 'codonDefault' * to run rapidly through the display without extra calls to SQL * for the same answer over and over. For other codon modes, it * will still need to query the Frames table repeatedly. * This was found to speed up dramatically by adding an index to * the table: * hgsql staAur2 -e 'CREATE INDEX src on multiz369wayFrames (src, bin);' */ - static char * extraPrevious = NULL; static struct mafFrames *mfList = NULL, *mf; static boolean found = FALSE; if (framesTable != NULL) { char extra[512]; if (sameString("codonDefault", codonTransMode)) { sqlSafef(extra, sizeof(extra), "src='%s'",defaultCodonSpecies); found = TRUE; } else if (sameString("codonFrameDef", codonTransMode)) { sqlSafef(extra, sizeof(extra), "src='%s'",mi->db); @@ -2680,30 +2687,32 @@ } static void wigMafDraw(struct track *track, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, MgFont *font, Color color, enum trackVisibility vis) /* Draw routine for wigmaf type tracks */ { int y = yOff; y = wigMafDrawScoreGraph(track, seqStart, seqEnd, hvg, xOff, y, width, font, color, vis); if (vis == tvFull || vis == tvPack) { if (zoomedToBaseLevel) { + resetCache(); + struct wigMafItem *wiList = track->items; /* skip over cons wiggles */ struct track *wigTrack = track->subtracks; while (wigTrack) { wiList = wiList->next; wigTrack = wigTrack->next; } y = wigMafDrawBases(track, seqStart, seqEnd, hvg, xOff, y, width, font, color, vis, wiList); //MG_RED, vis, wiList); } else wigMafDrawPairwise(track, seqStart, seqEnd, hvg, xOff, y, width, font, color, vis);