Bio-Graphics
view release on metacpan or search on metacpan
lib/Bio/Graphics/Glyph/cds.pm view on Meta::CPAN
$strand *= -1 if $self->{flip};
$y += ($y2-$y1)/2 if $self->sixframe && $strand < 0;
# have to remap feature start and end into pixel coords in order to:
# 1) correctly align the amino acids with the nucleotide seq
# 2) correct for the phase offset
my $start = $self->map_no_trunc($feature->start + $self->{cds_offset});
my $stop = $self->map_no_trunc($feature->end + $self->{cds_offset});
($start,$stop) = ($stop,$start) if $stop < $start; # why does this keep happening?
my @residues = split '',$self->{cds_translation};
push @residues,$self->{cds_splice_residue} if $self->{cds_splice_residue};
for (my $i=0;$i<@residues;$i++) {
my $x = $strand > 0 ? $start + $i * $pixels_per_residue
: $stop - $i * $pixels_per_residue;
next unless ($x >= $x1 && $x <= $x2);
$x -= $fontwidth + 1 if $self->{flip}; # align right when flipped
$gd->char($font,$x+1,$y,$residues[$i],$color);
}
}
sub make_key_feature {
my $self = shift;
my @gatc = qw(g a t c);
my $offset = $self->panel->offset;
my $scale = 1/$self->scale; # base pairs/pixel
my $start = $offset;
my $stop = $offset + 100 * $scale;
my $seq = join('',map{$gatc[rand 4]} (1..1500));
my $feature =
Bio::Graphics::Feature->new(-start=> $start,
-end => $stop,
-seq => $seq,
-name => $self->option('key'),
-strand=> +1,
);
$feature->add_segment(Bio::Graphics::Feature->new(
-start=> $start,
-end => $start + ($stop - $start)/2,
-seq => $seq,
-name => $self->option('key'),
-strand=> +1,
),
Bio::Graphics::Feature->new(
-start=> $start + ($stop - $start)/2+1,
-end => $stop,
-seq => $seq,
-name => $self->option('key'),
-phase=> 1,
-strand=> +1,
));
$feature;
}
# never allow our components to bump
sub bump {
my $self = shift;
return $self->SUPER::bump(@_) if $self->all_callbacks;
return 0;
}
1;
__END__
=head1 NAME
Bio::Graphics::Glyph::cds - The "cds" glyph
=head1 SYNOPSIS
See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
=head1 DESCRIPTION
This glyph draws features that are associated with a protein coding
region. At high magnifications, draws a series of boxes that are
color-coded to indicate the frame in which the translation occurs. At
low magnifications, draws the amino acid sequence of the resulting
protein. Amino acids that are created by a splice are optionally
shown in a distinctive color.
=head2 OPTIONS
The following options are standard among all Glyphs. See
L<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)
-strand_arrow Whether to indicate 0 (false)
strandedness
-hilite Highlight color undef (no color)
( run in 0.599 second using v1.01-cache-2.11-cpan-39bf76dae61 )