src/hg/hgTracks/netTrack.c 1.24
1.24 2009/03/17 04:35:42 hiram
allow net tracks to color by gray scale, and fixing chain tracks Ui options
Index: src/hg/hgTracks/netTrack.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/netTrack.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -b -B -U 4 -r1.23 -r1.24
--- src/hg/hgTracks/netTrack.c 20 Feb 2008 00:42:27 -0000 1.23
+++ src/hg/hgTracks/netTrack.c 17 Mar 2009 04:35:42 -0000 1.24
@@ -8,12 +8,19 @@
#include "jksql.h"
#include "hdb.h"
#include "hgTracks.h"
#include "chainNet.h"
+#include "chainCart.h"
#include "chainNetDbLoad.h"
static char const rcsid[] = "$Id$";
+struct cartOptions
+ {
+ enum netColorEnum netColor; /* ChromColors, GrayScale */
+ int levelFilter ; /* filter chains by level 1 thru 6 */
+ };
+
struct netItem
/* A net track item. */
{
struct netItem *next;
@@ -76,11 +83,27 @@
{
netColorLastChrom = "UNKNOWN";
}
-static Color netColor(char *chrom)
+static Color netColor(struct track *tg, char *chrom, int level)
/* return appropriate color for a chromosome/scaffold */
{
+struct cartOptions *netCart;
+
+netCart = (struct cartOptions *) tg->extraUiData;
+
+if (netCart->netColor == netColorGrayScale)
+ switch(level)
+ {
+ case 1: return(shadesOfGray[9]); break;
+ case 2: return(shadesOfGray[7]); break;
+ case 3: return(shadesOfGray[6]); break;
+ case 4: return(shadesOfGray[5]); break;
+ case 5: return(shadesOfGray[4]); break;
+ case 6: return(shadesOfGray[3]); break;
+ default: return(shadesOfGray[2]); break;
+ }
+
static Color color;
if (!sameString(chrom, netColorLastChrom))
color = getSeqColor(chrom, rHvg);
if (0 == color)
@@ -165,9 +188,9 @@
}
}
-static void rNetDraw(struct hvGfx *hvg, struct cnFill *fillList, int level, int y)
+static void rNetDraw(struct track *tg, struct hvGfx *hvg, struct cnFill *fillList, int level, int y)
/* Recursively draw net. */
{
struct cnFill *fill;
struct cnFill *gap;
@@ -175,9 +198,9 @@
int orientation;
for (fill = fillList; fill != NULL; fill = fill->next)
{
- color = netColor(fill->qName);
+ color = netColor(tg, fill->qName, level);
invColor = hvGfxContrastingColor(rHvg, color);
orientation = orientFromChar(fill->qStrand);
if (fill->children == NULL || fill->tSize * rScale < 2.5)
/* Draw single solid box if no gaps or no room to draw gaps. */
@@ -204,9 +227,9 @@
for (gap = fill->children; gap != NULL; gap = gap->next)
{
if (gap->children)
{
- rNetDraw(hvg, gap->children, level+2, y + rNextLine);
+ rNetDraw(tg, hvg, gap->children, level+2, y + rNextLine);
}
}
}
}
@@ -241,9 +264,9 @@
rNextLine = 0;
rScale = scaleForPixels(width);
/* Recursively do main bit of work. */
- rNetDraw(hvg, net->fillList, 1, yOff);
+ rNetDraw(tg, hvg, net->fillList, 1, yOff);
chainNetFree(&net);
}
if (vis == tvDense)
mapBoxToggleVis(hvg, xOff, yOff, width, tg->heightPer, tg);
@@ -251,8 +274,19 @@
void netMethods(struct track *tg)
/* Make track group for chain/net alignment. */
{
+struct cartOptions *netCart;
+
+AllocVar(netCart);
+
+netCart->netColor = netColorStringToEnum(
+ trackDbSettingClosestToHomeOrDefault(tg->tdb, NET_COLOR, CHROM_COLORS));
+/* allow cart to override trackDb */
+netCart->netColor = netColorStringToEnum(
+ cartUsualStringClosestToHome(cart, tg->tdb, FALSE, NET_COLOR,
+ netColorEnumToString(netCart->netColor)));
+
tg->loadItems = netLoad;
tg->freeItems = netFree;
tg->drawItems = netDraw;
tg->itemName = netName;
@@ -261,6 +295,6 @@
tg->itemHeight = tgFixedItemHeight;
tg->itemStart = tgItemNoStart;
tg->itemEnd = tgItemNoEnd;
tg->mapsSelf = TRUE;
+tg->extraUiData = (void *) netCart;
}
-