This glyph acts like graded_segments but the bgcolor of each segment (sub-feature)
can be individually set using the source field of the feature.
Each segment type color is specified using the following nomenclature:
-{source}_color => $color
For example, if the feature consists of a gene containing both
confirmed and unconfirmed exons, you can make the confirmed exons
green and the unconfirmed ones red this way:
-confirmed_color => 'green',
-unconfirmed_color => 'red'
The following options are standard among all Glyphs. See
Bio::Graphics::Glyph for a full explanation.
Option Description Default
------ ----------- -------
-fgcolor Foreground color black
-outlinecolor Synonym for -fgcolor
-bgcolor Background color turquoise
-fillcolor Synonym for -bgcolor
-linewidth Line width 1
-height Height of glyph 10
-font Glyph font gdSmallFont
-connector Connector type 0 (false)
-connector_color
Connector color black
-label Whether to draw a label 0 (false)
-description Whether to draw a description 0 (false)
None available.
sub draw
{ my $self = shift;
my @parts = $self->parts;
@parts = $self if !@parts && $self->level == 0;
return $self->SUPER::draw(@_) unless @parts;
$self->{source2color} ||= {};
my $fill = $self->bgcolor;
for my $part (@parts) {
my $s = eval { $part->feature->source_tag } or next;
$self->{source2color}{$s} ||= $self->color(lc($s)."_color") || $fill;
$part->{partcolor} = $self->{source2color}{$s};
}
$self->Bio::Graphics::Glyph::generic::draw(@_);
}
} |
sub keyglyph
{ my $self = shift;
my $scale = 1/$self->scale; # base pairs/pixel
my $offset = $self->panel->offset;
my $feature =
Bio::Graphics::Feature->new(
-segments=>[ [ 0*$scale +$offset,25*$scale+$offset],
[ 25*$scale +$offset,50*$scale+$offset],
[ 50*$scale+$offset, 75*$scale+$offset]
],
-name => $self->option('key'),
-strand => '+1');
my @sources = grep {/_color$/} $self->factory->options;
foreach (@sources) {s/_color$//}
($feature->segments)[0]->source_tag($sources[1]);
($feature->segments)[1]->source_tag($sources[0]);
($feature->segments)[2]->source_tag($sources[2]);
my $factory = $self->factory->clone;
$factory->set_option(label => 1);
$factory->set_option(bump => 0);
$factory->set_option(connector => 'solid');
my $glyph = $factory->make_glyph(0,$feature);
return $glyph;
}
1; } |
Please report them.