void hCytoBandDrawAt(struct cytoBand *band, struct hvGfx *hvg, int x, int y, int width, int height, boolean isDmel, MgFont *font, int fontPixelHeight, Color aColor, Color bColor, Color *shades, int maxShade) /* Draw a single band in appropriate color at given position. If there's * room put in band label. */ { Color col = hCytoBandColor(band, hvg, isDmel, aColor, bColor, shades, maxShade); hvGfxBox(hvg, x, y, width, height, col); if (height >= mgFontLineHeight(font)) { char *s = abbreviatedBandName(band, font, width, isDmel); if (s != NULL) { Color textCol = hvGfxContrastingColor(hvg, col); hvGfxTextCentered(hvg, x, y, width, height, textCol, font, s); } } }
void bamDrawAt(struct track *tg, void *item, struct hvGfx *hvg, int xOff, int y, double scale, MgFont *font, Color color, enum trackVisibility vis) /* 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; 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, "*")) { drawOpt = baseColorDrawSetup(hvg, tg, lf, &mrnaSeq, &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) { // In bamTrack, lf->filterColor is an RGBA value color = lf->filterColor; } else if (tg->colorShades) color = tg->colorShades[lf->grayIx]; 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); 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, drawOpt, indelShowQueryInsert, indelShowPolyA); baseColorOverdrawDiff(tg, lf, hvg, xOff, y, scale, heightPer, mrnaSeq, psl, winStart, drawOpt); baseColorDrawCleanup(lf, &mrnaSeq, &psl); } }