7e6bfce5ff65b67d6e75b239c8b7fb3270f475fb
kent
  Wed Jun 29 19:11:10 2022 -0700
Making baseColorDrawItem(), baseColorOverdrawDiff(), and baseColorOverdrawQInsert() functions to from mrnaSeq parameter to qSeq/qOffset parameter pair.  Currently qOffset is always zero, but have plans to use it so that not necessarily all of query sequence needs to be loaded.  qSeq may be a whole chromosome for a chain.

diff --git src/hg/hgTracks/bamTrack.c src/hg/hgTracks/bamTrack.c
index 3cf543c..4880896 100644
--- src/hg/hgTracks/bamTrack.c
+++ src/hg/hgTracks/bamTrack.c
@@ -600,42 +600,43 @@
 /* Draw a single bam linkedFeatures item.  Borrows a lot from linkedFeaturesDrawAt,
  * but cuts a lot of unneeded features (like coding region) and adds a couple
  * additional sources of color. */
 {
 struct linkedFeatures *lf = item;
 struct simpleFeature *sf;
 int heightPer = tg->heightPer;
 int x1 = round((double)((int)lf->start-winStart)*scale) + xOff;
 int x2 = round((double)((int)lf->end-winStart)*scale) + xOff;
 int w = x2-x1;
 int midY = y + (heightPer>>1);
 char *exonArrowsDense = trackDbSettingClosestToHome(tg->tdb, "exonArrowsDense");
 boolean exonArrowsEvenWhenDense = (exonArrowsDense != NULL && SETTING_IS_ON(exonArrowsDense));
 boolean exonArrows = (tg->exonArrows &&
 		      (vis != tvDense || exonArrowsEvenWhenDense));
-struct dnaSeq *mrnaSeq = NULL;
+struct dnaSeq *qSeq = NULL;
+int qOffset = 0;
 enum baseColorDrawOpt drawOpt = baseColorDrawOff;
 boolean indelShowDoubleInsert, indelShowQueryInsert, indelShowPolyA;
 struct psl *psl = (struct psl *)(lf->original);
 char *colorMode = cartOrTdbString(cart, tg->tdb, BAM_COLOR_MODE, BAM_COLOR_MODE_DEFAULT);
 char *grayMode = cartOrTdbString(cart, tg->tdb, BAM_GRAY_MODE, BAM_GRAY_MODE_DEFAULT);
 bool baseQualMode = (sameString(colorMode, BAM_COLOR_MODE_GRAY) &&
 		     sameString(grayMode, BAM_GRAY_MODE_BASE_QUAL));
-char *qSeq = lf->extra;
-if (vis != tvDense && isNotEmpty(qSeq) && !sameString(qSeq, "*"))
+char *qSeqName = lf->extra;
+if (vis != tvDense && isNotEmpty(qSeqName) && !sameString(qSeqName, "*"))
     {
-    drawOpt = baseColorDrawSetup(hvg, tg, lf, &mrnaSeq, &psl);
+    drawOpt = baseColorDrawSetup(hvg, tg, lf, &qSeq, &qOffset, &psl);
     if (drawOpt > baseColorDrawOff)
 	exonArrows = FALSE;
     }
 
 static Color darkBlueColor = 0;
 static Color darkRedColor = 0;
 if (darkRedColor == 0)
     {
     darkRedColor = hvGfxFindColorIx(hvg, 100,0,0);
     darkBlueColor = hvGfxFindColorIx(hvg, 0,0,100);
     }
 if (sameString(colorMode, BAM_COLOR_MODE_STRAND))
     color = (lf->orientation < 0) ? darkRedColor : darkBlueColor;
 else if (lf->filterColor != 0)
     {
@@ -647,60 +648,60 @@
 else
     color = tg->ixColor;
 
 indelEnabled(cart, tg->tdb, basesPerPixel, &indelShowDoubleInsert, &indelShowQueryInsert,
 	     &indelShowPolyA);
 if (!indelShowDoubleInsert)
     innerLine(hvg, x1, midY, w, color);
 for (sf = lf->components; sf != NULL; sf = sf->next)
     {
     int s = sf->start,  e = sf->end;
     if (e <= s || e < winStart || s > winEnd)
 	continue;
     if (baseQualMode)
 	color = tg->colorShades[sf->grayIx];
     baseColorDrawItem(tg, lf, sf->grayIx, hvg, xOff, y, scale, font, s, e, heightPer,
-		      zoomedToCodonLevel, mrnaSeq, sf, psl, drawOpt, MAXPIXELS, winStart, color);
+		      zoomedToCodonLevel, qSeq, qOffset, sf, psl, drawOpt, MAXPIXELS, winStart, color);
     if (tg->exonArrowsAlways ||
 	(exonArrows &&
 	 (sf->start <= winStart || sf->start == lf->start) &&
 	 (sf->end >= winEnd || sf->end == lf->end)))
 	{
 	Color barbColor = hvGfxContrastingColor(hvg, color);
 	x1 = round((double)((int)s-winStart)*scale) + xOff;
 	x2 = round((double)((int)e-winStart)*scale) + xOff;
 	w = x2-x1;
 	clippedBarbs(hvg, x1+1, midY, x2-x1-2, tl.barbHeight, tl.barbSpacing, lf->orientation,
 		     barbColor, TRUE);
 	}
     }
 if (indelShowDoubleInsert && psl)
     {
     int intronGap = 0;
     if (vis != tvDense)
 	intronGap = atoi(trackDbSettingClosestToHomeOrDefault(tg->tdb, "intronGap", "0"));
     lfDrawSpecialGaps(lf, intronGap, TRUE, 0, tg, hvg, xOff, y, scale, color, color, vis);
     }
 if (vis != tvDense)
     {
     /* If highlighting differences between aligned sequence and genome when
      * zoomed way out, this must be done in a separate pass after exons are
      * drawn so that exons sharing the pixel don't overdraw differences. */
     if ((indelShowQueryInsert || indelShowPolyA) && psl)
-	baseColorOverdrawQInsert(tg, lf, hvg, xOff, y, scale, heightPer, mrnaSeq, psl, winStart,
+	baseColorOverdrawQInsert(tg, lf, hvg, xOff, y, scale, heightPer, qSeq, qOffset, psl, winStart,
 				 drawOpt, indelShowQueryInsert, indelShowPolyA);
-    baseColorOverdrawDiff(tg, lf, hvg, xOff, y, scale, heightPer, mrnaSeq, psl, winStart, drawOpt);
+    baseColorOverdrawDiff(tg, lf, hvg, xOff, y, scale, heightPer, qSeq, qOffset, psl, winStart, drawOpt);
     }
 }
 
 void bamPairedDrawAt(struct track *tg, void *item, struct hvGfx *hvg, int xOff, int y,
 		     double scale, MgFont *font, Color color, enum trackVisibility vis)
 /* Draw a bam linked features series item at position. (like linkedFeaturesSeriesDrawAt,
  * but calls bamDrawAt instead of linkedFeaturesDrawAt) */
 {
 struct linkedFeaturesSeries *lfs = item;
 struct linkedFeatures *lf;
 int midY = y + (tg->heightPer>>1);
 int prevEnd = lfs->start;
 
 if ((lf = lfs->features) == NULL)
     return;