Skip to content

Commit

Permalink
add -color_cycle option to control automatic background color selection
Browse files Browse the repository at this point in the history
  • Loading branch information
lstein committed Feb 10, 2012
1 parent ee4968a commit fac8589
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Revision history for Perl extension Bio::Graphics.
2.26
- Support for normalizing quantitative plots across entire track.
- Support for transparency within tracks, allowing features to overlap.
- Support for -color_series and -color_cycle options (see Bio::Graphics::Panel)
which cycle dynamically among a fixed series of background colors.

2.25
- Deprecate xyplot "histogram" subtype and default to "boxes".
Expand Down
3 changes: 2 additions & 1 deletion lib/Bio/Graphics/FeatureFile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ END
} else {
mkpath(dirname($cachefile));
my $parsed = $self->_new(@_);
lock_store($parsed,$cachefile);
eval {lock_store($parsed,$cachefile)};
warn $@ if $@;
return $parsed;
}

Expand Down
7 changes: 4 additions & 3 deletions lib/Bio/Graphics/Glyph/track.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ sub draw {
$self->normalize_track(@parts);

# dynamic assignment of colors
if ($self->option('color_series')) {
my @color_series =
qw(red blue green yellow orange brown aqua black fuchsia green lime maroon navy olive purple silver teal magenta);
if ($self->option('color_series') || $self->option('color_cycle')) {
my $series = $self->option('color_cycle');
$series ||= 'red blue green yellow orange brown aqua black fuchsia green lime maroon navy olive purple silver teal magenta';
my @color_series = ref($series) eq 'ARRAY' ? @$series : split /\s+/,$series;
my $index = 0;
my %color_cache;
my $closure = sub {
Expand Down
12 changes: 8 additions & 4 deletions lib/Bio/Graphics/Panel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1961,10 +1961,14 @@ object to the panel. This stylesheet will be called to determine both
the glyph and the glyph options. If both a stylesheet and direct
options are provided, the latter take precedence.
The B<-color_series> argument, if true, causes the track to ignore
the -bgcolor setting and instead to assign glyphs a series of
contrasting colors. This is usually used in combination with
-bump=>'overlap' in order to create overlapping features.
The B<-color_series> argument causes the track to ignore the -bgcolor
setting and instead to assign glyphs a series of contrasting
colors. This is usually used in combination with -bump=>'overlap' in
order to create overlapping features. A true value activates the color
series. You may adjust the default color series using the
B<-color_cycle> option, which is either a reference to an array of
Bio::Graphics color values, or a space-delimited string of color
names/value.
If successful, add_track() returns an Bio::Graphics::Glyph object.
You can use this object to add additional features or to control the
Expand Down

0 comments on commit fac8589

Please sign in to comment.