src/hg/hgTracks/bedTrack.c 1.8
1.8 2009/05/22 10:11:16 mikep
added 'colorByStrand' option which specifies a + and - strand color to override the main 'color', currently works for bed/bigBed tracks which have base coloring
Index: src/hg/hgTracks/bedTrack.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/bedTrack.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -b -B -U 4 -r1.7 -r1.8
--- src/hg/hgTracks/bedTrack.c 20 May 2009 20:50:51 -0000 1.7
+++ src/hg/hgTracks/bedTrack.c 22 May 2009 10:11:16 -0000 1.8
@@ -686,8 +686,36 @@
loadSimpleBed(tg);
tg->items = simpleBedListToLinkedFeatures(tg->items, tg->bedSize, TRUE);
}
+
+Color lfItemColorByStrand(struct track *tg, void *item, struct hvGfx *hvg)
+/* Look up the RGB color from the trackDb setting 'colorByStrand' based on
+ * the linkedFeature item orientation, and convert this to a color index
+ * using hvGfx */
+{
+struct linkedFeatures *lf = item;
+char *words[3];
+unsigned char r, g, b;
+
+char *colors = cloneString(trackDbSetting(tg->tdb, "colorByStrand"));
+if (!colors)
+ errAbort("colorByStrand setting missing (in %s)", tg->mapName);
+if (chopByChar(colors, ':', words, sizeof(words)) != 2)
+ errAbort("invalid colorByStrand setting %s (expecting pair of RGB values r,g,b:r,g,b)", colors);
+if (lf->orientation == 1)
+ parseColor(words[0], &r, &g, &b);
+else if (lf->orientation == -1)
+ parseColor(words[1], &r, &g, &b);
+else // return the main color
+ {
+ r = tg->color.r; g = tg->color.g; b = tg->color.b;
+ }
+freez(&colors);
+return hvGfxFindColorIx(hvg, r, g, b);
+}
+
+
void complexBedMethods(struct track *track, struct trackDb *tdb, boolean isBigBed,
int wordCount, char *words[])
/* Fill in methods for more complex bed tracks. */
{
@@ -709,8 +737,10 @@
// data must be loaded as bed and converted to linkedFeatures
// to draw each base character must make one simpleFeature per base
linkedFeaturesMethods(track);
track->loadItems = loadSimpleBedAsLinkedFeaturesPerBase;
+ if (trackDbSetting(tdb, "colorByStrand"))
+ track->itemColor = lfItemColorByStrand;
}
else
{
bedMethods(track);