6c16a029709c60f4d88f5a2a01ef7422c78c89c4 braney Fri Sep 19 15:30:36 2014 -0700 show SNPs as red in maf and wigMaf tracks if "showSnp on" is set in the trackDb diff --git src/hg/hgTracks/mafTrack.c src/hg/hgTracks/mafTrack.c index d6adcaf..5c4104f 100644 --- src/hg/hgTracks/mafTrack.c +++ src/hg/hgTracks/mafTrack.c @@ -559,43 +559,48 @@ } */ for (x = xOff+1; x < xOff+width; x += 3) { hvGfxBox(hvg, x, yOff+height-5, 2, 3, fuzz); } } #else innerLine(hvg, xOff, midY, width, gray); #endif } void drawMafRegionDetails(struct mafAli *mafList, int height, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, MgFont *font, Color color, Color altColor, - enum trackVisibility vis, boolean isAxt, boolean chainBreaks) + enum trackVisibility vis, boolean isAxt, boolean chainBreaks, + boolean doSnpMode) /* Draw wiggle/density plot based on scoring things on the fly * from list of MAF */ { struct mafAli *full, *sub = NULL, *maf = NULL; struct mafComp *mcMaster, *mc; char dbChrom[64]; int height1 = height-2; int ixMafAli = 0; /* alignment index, to allow alternating color */ int x1, x2; int lastAlignX2 = -1; int lastChainX2 = -1; double scale = scaleForPixels(width); +if (doSnpMode) + mafScoreUseSimple(); +else + mafScoreUseTraditional(); safef(dbChrom, sizeof(dbChrom), "%s.%s", database, chromName); for (full = mafList; full != NULL; full = full->next) { double *pixelScores = NULL; int i; int w; sub = NULL; if (mafNeedSubset(full, dbChrom, seqStart, seqEnd)) sub = maf = mafSubset(full, dbChrom, seqStart, seqEnd); else maf = full; if (maf != NULL) { ixMafAli++; @@ -654,35 +659,46 @@ for (i=0; i<w; ++i) { if (vis == tvFull) { int y = pixelScores[i] * height1; hvGfxBox(hvg, i+x1, yOff + height1 - y, 1, y+1, (ixMafAli % 2) ? color : altColor); } else { int shade = (pixelScores[i] * maxShade) + 1; Color c; if (shade > maxShade) shade = maxShade; c = shadesOfGray[shade]; + if (doSnpMode) + { // draw mismatched bases as RED - if (pixelScores[i] < 1.0) + if (pixelScores[i] == 0.0) + { c = MG_RED; hvGfxBox(hvg, i+x1, yOff, 1, height - 1, c); } + else if (pixelScores[i] == 1.0) + hvGfxBox(hvg, i+x1, yOff, 1, height - 1, c); + } + else + { + hvGfxBox(hvg, i+x1, yOff, 1, height - 1, c); + } + } } if (vis != tvFull && mc->leftStatus == MAF_NEW_NESTED_STATUS) { hvGfxBox(hvg, x1-1, yOff, 2, 1, getChromBreakGreenColor()); hvGfxBox(hvg, x1-1, yOff, 1, height, getChromBreakGreenColor()); hvGfxBox(hvg, x1-1, yOff + height-1, 2, 1, getChromBreakGreenColor()); } if (vis != tvFull && mc->rightStatus == MAF_NEW_NESTED_STATUS) { hvGfxBox(hvg, i+x1-1, yOff, 2, 1, getChromBreakGreenColor()); hvGfxBox(hvg, i+x1, yOff, 1, height, getChromBreakGreenColor()); hvGfxBox(hvg, i+x1-1, yOff + height-1, 2, 1, getChromBreakGreenColor()); } @@ -694,61 +710,64 @@ if (sub != NULL) mafAliFree(&sub); } } static void mafDrawDetails(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, MgFont *font, Color color, enum trackVisibility vis, boolean isAxt) /* Draw wiggle/density plot based on scoring things on the fly. */ { struct mafAli *mafList; struct sqlConnection *conn = hAllocConn(database); struct mafItem *miList = tg->items, *mi = miList; char *suffix; struct mafPriv *mp = getMafPriv(tg); +boolean doSnpMode = (vis == tvPack) &&(trackDbSetting(tg->tdb, "snpMode") != NULL); mafList = mp->list; if (mafList == NULL) mafList = mafOrAxtLoadInRegion(conn, tg, chromName, seqStart, seqEnd, isAxt); /* display the multiple alignment in this region */ drawMafRegionDetails(mafList, mi->height, seqStart, seqEnd, hvg, xOff, yOff, - width, font, color, tg->ixAltColor, vis, isAxt, FALSE); + width, font, color, tg->ixAltColor, vis, isAxt, FALSE, + doSnpMode); mafAliFreeList(&mafList); yOff += mi->height + 1; if (vis == tvFull) { while ((mi = mi->next) != NULL) { /* construct pairwise table name for this organism */ /* if there's a value for the "pairwise" trackDb setting, use this * to construct the tablename, otherwise, use the track name */ char mafTable[64]; if ((suffix = trackDbSetting(tg->tdb, "pairwise")) == NULL || *suffix == 0) suffix = tg->table; safef(mafTable, sizeof(mafTable), "%s_%s", mi->name, suffix); if (!hTableExists(database, mafTable)) continue; mafList = mafLoadInRegion(conn, mafTable, chromName, seqStart, seqEnd); /* display pairwise alignments in this region in dense format */ drawMafRegionDetails(mafList, mi->height, seqStart, seqEnd, hvg, xOff, yOff, width, font, - color, tg->ixAltColor, tvDense, isAxt, FALSE); + color, tg->ixAltColor, tvDense, isAxt, FALSE, + doSnpMode); yOff += mi->height + 1; mafAliFreeList(&mafList); } } hFreeConn(&conn); } static void mafDrawGraphic(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, MgFont *font, Color color, enum trackVisibility vis, boolean isAxt) /* Draw wiggle or density plot, not base-by-base. */ { int seqSize = seqEnd - seqStart; if (seqSize >= MAF_SUMMARY_VIEW) {