Bio::Graphics::Glyph graded_segments
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
Bio::Graphics::Glyph::graded_segments - The "graded_segments" glyph
Package variables
No package variables defined.
Included modules
Bio::Graphics::Glyph::segments
Inherit
Bio::Graphics::Glyph::segments
Synopsis
  See Bio::Graphics::Panel and Bio::Graphics::Glyph.
Description
This is identical to the "alignment" glyph, and is used for
drawing features that consist of discontinuous segments. The
color intensity of each segment is proportionate to the score. 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)
In addition, the alignment glyph recognizes the following
glyph-specific options:
  Option      Description                  Default
------ ----------- -------
-max_score Maximum value of the Calculated feature's "score" attribute -min_score Minimum value of the Calculated feature's "score" attribute
If max_score and min_score are not specified, then the glyph will
calculate the local maximum and minimum scores at run time.
Methods
bgcolor
No description
Code
calculate_color
No description
Code
draw
No description
Code
fgcolor
No description
Code
keyglyph
No description
Code
max
No description
Code
subseq
No description
Code
Methods description
None available.
Methods code
bgcolordescriptionprevnextTop
sub bgcolor {
   my $self = shift;
  return $self->{partcolor} || $self->SUPER::bgcolor;
}
calculate_colordescriptionprevnextTop
sub calculate_color {
  my $self = shift;
  my ($s,$rgb,$min_score,$span) = @_;
  return map { 255 - (255-$_) * min(max( ($s-$min_score)/$span, 0), 1) } @$rgb;
}
drawdescriptionprevnextTop
sub draw {
  my $self = shift;

  # bail out if this isn't the right kind of feature
# handle both das-style and Bio::SeqFeatureI style,
# which use different names for subparts.
my @parts = $self->parts; @parts = $self if !@parts && $self->level == 0; return $self->SUPER::draw(@_) unless @parts; # figure out the colors
my $max_score = $self->option('max_score'); my $min_score = $self->option('min_score'); unless (defined $max_score && defined $min_score) { for my $part (@parts) { my $s = eval { $part->feature->score }; next unless defined $s; $max_score = $s if !defined $max_score or $s > $max_score; $min_score = $s if !defined $min_score or $s < $min_score; } } return $self->SUPER::draw(@_) unless defined($max_score) && defined($min_score) && $min_score < $max_score; my $span = $max_score - $min_score; # allocate colors
my $fill = $self->bgcolor; my ($red,$green,$blue) = $self->panel->rgb($fill); foreach my $part (@parts) { my $s = eval { $part->feature->score }; unless (defined $s) { $part->{partcolor} = $fill; next; } my ($r,$g,$b) = $self->calculate_color($s,[$red,$green,$blue],$min_score,$span); my $idx = $self->panel->translate_color($r,$g,$b); $part->{partcolor} = $idx; } $self->SUPER::draw(@_);
}
fgcolordescriptionprevnextTop
sub fgcolor {
   my $self = shift;
  return $self->{partcolor} || $self->SUPER::fgcolor;
}

1;
}
keyglyphdescriptionprevnextTop
sub keyglyph {
  my $self = shift;

  my $scale = 1/$self->scale;  # base pairs/pixel

  # two segments, at pixels 0->50, 60->80
my $offset = $self->panel->offset; my $feature = Bio::Graphics::Feature->new( -segments=>[ [ 0*$scale +$offset,20*$scale+$offset], [ 30*$scale +$offset,50*$scale+$offset], [60*$scale+$offset, 80*$scale+$offset] ], -name => $self->option('key'), -strand => '+1'); ($feature->segments)[0]->score(10); ($feature->segments)[1]->score(50); ($feature->segments)[2]->score(100); my $factory = $self->factory->clone; $factory->set_option(label => 1); $factory->set_option(bump => 0); $factory->set_option(connector => 'solid'); return $factory->make_glyph($feature); } # component draws a shaded box
}
maxdescriptionprevnextTop
sub max {
 $_[0] > $_[1] ? $_[0] : $_[1]
}
subseqdescriptionprevnextTop
sub subseq {
  my $class = shift;
  my $feature = shift;
  return $feature->segments        if $feature->can('segments');
  return $feature->sub_SeqFeature  if $feature->can('sub_SeqFeature');
  return;
}

# synthesize a key glyph
}
General documentation
BUGSTop
Please report them.
SEE ALSOTop
Bio::Graphics::Panel,
Bio::Graphics::Glyph,
Bio::Graphics::Glyph::arrow,
Bio::Graphics::Glyph::cds,
Bio::Graphics::Glyph::crossbox,
Bio::Graphics::Glyph::diamond,
Bio::Graphics::Glyph::dna,
Bio::Graphics::Glyph::dot,
Bio::Graphics::Glyph::ellipse,
Bio::Graphics::Glyph::extending_arrow,
Bio::Graphics::Glyph::generic,
Bio::Graphics::Glyph::graded_segments,
Bio::Graphics::Glyph::heterogeneous_segments,
Bio::Graphics::Glyph::line,
Bio::Graphics::Glyph::pinsertion,
Bio::Graphics::Glyph::primers,
Bio::Graphics::Glyph::rndrect,
Bio::Graphics::Glyph::segments,
Bio::Graphics::Glyph::ruler_arrow,
Bio::Graphics::Glyph::toomany,
Bio::Graphics::Glyph::transcript,
Bio::Graphics::Glyph::transcript2,
Bio::Graphics::Glyph::translation,
Bio::Graphics::Glyph::triangle,
Bio::DB::GFF,
Bio::SeqI,
Bio::SeqFeatureI,
Bio::Das,
GD
AUTHORTop
Lincoln Stein <lstein@cshl.org>
Copyright (c) 2001 Cold Spring Harbor Laboratory
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself. See DISCLAIMER.txt for
disclaimers of warranty.