73bc761688e8dc33888081e7e9198d3f214c90b8 braney Fri Aug 7 14:21:33 2015 -0700 some tweaks to introduce mafSnp mode to hg38 100way #14277 diff --git src/hg/hgTracks/wigMafTrack.c src/hg/hgTracks/wigMafTrack.c index 03747cd..e163fa7 100644 --- src/hg/hgTracks/wigMafTrack.c +++ src/hg/hgTracks/wigMafTrack.c @@ -284,31 +284,31 @@ char *getCustomMafFile(struct track *track) { char *fileName = getTrackMafFile(track); if (fileName == NULL) errAbort("cannot find custom maf setting"); return fileName; } static void loadMafsToTrack(struct track *track) /* load mafs in region to track custom pointer */ { struct sqlConnection *conn; struct sqlConnection *conn2; struct mafPriv *mp = getMafPriv(track); -if (winBaseCount > MAF_SUMMARY_VIEW) +if (inSummaryMode(cart, track->tdb, winBaseCount)) return; int begin = winStart - 2; if (begin < 0) begin = 0; /* we open two connections to the database * that has the maf track in it. One is * for the scoredRefs, the other to access * the extFile database. We could get away * with just one connection, but then we'd * have to allocate more memory to hold * the scoredRefs (whereas now we just use * one statically loaded scoredRef). */ @@ -454,31 +454,31 @@ return cloneString(table); } static char *getMafTablename(char *species, char *suffix) /* generate tablename for wiggle maf: "<species>_<table>" */ { char table[64]; safef(table, sizeof(table), "%s_%s", species, suffix); return cloneString(table); } static boolean displayPairwise(struct track *track) /* determine if tables are present for pairwise display */ { -return winBaseCount < MAF_SUMMARY_VIEW || isCustomTrack(track->table) || +return !inSummaryMode(cart, track->tdb, winBaseCount) || isCustomTrack(track->table) || pairwiseSuffix(track) || summarySetting(track); } static boolean displayZoomedIn(struct track *track) /* determine if mafs are loaded -- zoomed in display */ { struct mafPriv *mp = getMafPriv(track); return mp->list != (char *)-1; } static void markNotPairwiseItem(struct wigMafItem *mi) { mi->ix = -1; } @@ -493,31 +493,31 @@ for each "other species" in the multiple alignment. These may be density plots (pack) or wiggles (full). Return item list. Also set customPt with mafList if zoomed in */ { struct wigMafItem *miList = NULL, *speciesItems = NULL, *mi; struct track *wigTrack = track->subtracks; int scoreHeight = tl.fontHeight * 4; char *snpTable = trackDbSetting(track->tdb, "snpTable"); boolean doSnpTable = FALSE; if ( (track->limitedVis == tvPack) && (snpTable != NULL) && cartOrTdbBoolean(cart, track->tdb, MAF_SHOW_SNP,FALSE)) doSnpTable = TRUE; // the maf's only get loaded if we're not in summary or snpTable views -if (!doSnpTable && (winBaseCount < MAF_SUMMARY_VIEW)) +if (!doSnpTable && !inSummaryMode(cart, track->tdb, winBaseCount)) { /* "close in" display uses actual alignments from file */ struct mafPriv *mp = getMafPriv(track); struct sqlConnection *conn, *conn2; if (mp->ct) { char *fileName = getCustomMafFile(track); conn = hAllocConn(CUSTOM_TRASH); conn2 = hAllocConn(CUSTOM_TRASH); mp->list = wigMafLoadInRegion(conn, conn2, mp->ct->dbTableName, chromName, winStart, winEnd, fileName); hFreeConn(&conn); hFreeConn(&conn2); } @@ -561,74 +561,74 @@ static struct wigMafItem *loadWigMafItems(struct track *track, boolean isBaseLevel) /* Load up items */ { struct wigMafItem *miList = NULL, *mi; int scoreHeight = tl.fontHeight * 4; struct track *wigTrack = track->subtracks; struct mafPriv *mp = getMafPriv(track); mp->list = (char *)-1; /* no maf's loaded or attempted to load */ /* if we're out in summary view and rendering a custom * track we force dense mode since we don't have * a summary table (yet). */ -if ((winBaseCount >= MAF_SUMMARY_VIEW) && isCustomTrack(track->table)) +if (inSummaryMode(cart, track->tdb, winBaseCount) && isCustomTrack(track->table)) track->limitedVis = tvDense; /* Load up mafs and store in track so drawer doesn't have * to do it again. */ /* Make up tracks for display. */ if (track->limitedVis == tvFull || track->limitedVis == tvPack) { if (isBaseLevel) { miList = loadBaseByBaseItems(track); } /* zoomed out */ else { miList = loadPairwiseItems(track); } } else if (track->limitedVis == tvSquish) { if (!wigTrack) { scoreHeight = tl.fontHeight * 4; - if (winBaseCount < MAF_SUMMARY_VIEW) + if (!inSummaryMode(cart, track->tdb, winBaseCount)) loadMafsToTrack(track); /* not a real meausre of conservation, so don't label it so */ miList = scoreItem(scoreHeight, ""); } else while (wigTrack) { /* have a wiggle */ scoreHeight = wigTotalHeight(wigTrack, tvFull); mi = scoreItem(scoreHeight, wigTrack->shortLabel); slAddTail(&miList, mi); wigTrack = wigTrack->next; } } else { /* dense mode, zoomed out - show density plot, with track label */ if (!wigTrack) { /* no wiggle -- use mafs if close in */ - if (winBaseCount < MAF_SUMMARY_VIEW) + if (!inSummaryMode(cart, track->tdb, winBaseCount)) #ifndef NOTYET loadMafsToTrack(track); AllocVar(miList); miList->name = cloneString(track->shortLabel); miList->height = tl.fontHeight; #else miList = loadPairwiseItems(track); /* remove components that aren't selected */ struct wigMafItem *mil = miList; struct hash *nameHash = newHash(5); for(;mil; mil = mil->next) hashStore(nameHash, mil->name); struct mafPriv *mp = getMafPriv(track); @@ -1073,30 +1073,36 @@ { hvGfxSetClip(hvg, xOff, yOff, width, mi->height); struct bed *bed = bedList; double scale = scaleForPixels(width); for(; bed; bed = bed->next) { int x1 = round((bed->chromStart - seqStart)*scale); int x2 = round((bed->chromEnd - seqStart)*scale); int w = x2-x1+1; int height1 = mi->height-1; int color = MG_BLACK; switch(bed->score) { + case 222: // place holder for heterozygous nonsynonymous + color = 0xff000000; + break; + case 111: // place holder for heterozygous synonymous + color = 0xffd0e040; + break; case 0: color = yellow; break; case _5_prime_UTR_variant: case _3_prime_UTR_variant: case coding_sequence_variant: case intron_variant: case intergenic_variant: color = MG_BLUE; break; case synonymous_variant: color = MG_GREEN; break; case missense_variant: color = MG_RED; @@ -1450,31 +1456,31 @@ * When zoomed in, use on-the-fly scoring of alignments extracted from multiple * When zoomed out: * if "pairwise" setting is on, use pairwise tables (maf or wiggle) * <species>_<suffix> for maf, <species>_<suffix>_wig for wiggle * For full mode, display graph. * for pack mode, display density plot. * if "summary" setting is on, use maf summary table * (saves space, and performs better) */ { if (displayZoomedIn(track)) return drawPairsFromMultipleMaf(track, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis); if (isCustomTrack(track->table) || pairwiseSuffix(track)) return drawPairsFromPairwiseMafScores(track, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis); - if ((winBaseCount >= MAF_SUMMARY_VIEW) && summarySetting(track)) + if (inSummaryMode(cart, track->tdb, winBaseCount) && summarySetting(track)) return drawPairsFromSummary(track, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis); char *snpTable = trackDbSetting(track->tdb, "snpTable"); if ( (track->limitedVis == tvPack) && (snpTable != NULL)) return drawPairsFromSnpTable(track, snpTable, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis); return FALSE; } static void alternateBlocksBehindChars(struct hvGfx *hvg, int x, int y, int width, int height, int charWidth, int charCount, int stripeCharWidth, Color a, Color b) /* Draw blocks that alternate between color a and b. */ {