| 1 | package Bio::Graphics::Glyph::operon; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use base 'Bio::Graphics::Glyph::segments'; | ||
| 5 | #use Data::Dumper; | ||
| 6 | |||
| 7 | sub draw_component { | ||
| 8 | my $self = shift; | ||
| 9 | my ($gd,$dx,$dy) = @_; | ||
| 10 | my ($left,$top,$right,$bottom) = $self->bounds($dx,$dy); | ||
| 11 | |||
| 12 | my $feature = $self->feature; | ||
| 13 | |||
| 14 | $feature->type =~ /^([\S_]+):/; | ||
| 15 | |||
| 16 | if ($1 eq 'TSS') { | ||
| 17 | |||
| 18 | # draw the promoter as an arrow | ||
| 19 | if ($feature->strand == 1){ | ||
| 20 | $self->vline($gd, $left, $top-5, ($top+$bottom)/2); | ||
| 21 | $self->arrow($gd,$left,$left+5,$top-5); | ||
| 22 | } | ||
| 23 | if ($feature->strand == -1){ | ||
| 24 | $self->vline($gd, $right, $top-5, ($top+$bottom)/2); | ||
| 25 | $self->arrow($gd,$right,$right-5,$top-5); | ||
| 26 | } | ||
| 27 | return; | ||
| 28 | |||
| 29 | } | ||
| 30 | if ($1 eq 'terminator') { | ||
| 31 | |||
| 32 | # draw the terminator as an lollipop | ||
| 33 | if ($feature->strand >= 0){ | ||
| 34 | $self->vline($gd, $right, $top-5, ($top+$bottom)/2); | ||
| 35 | $gd->filledEllipse($right,$top-4,6,6,$self->translate_color('red')); | ||
| 36 | } | ||
| 37 | if ($feature->strand < 0){ | ||
| 38 | $self->vline($gd, $left, $top-5, ($top+$bottom)/2); | ||
| 39 | $gd->filledEllipse($left,$top-4,6,6,$self->translate_color('red')); | ||
| 40 | } | ||
| 41 | return; | ||
| 42 | |||
| 43 | } | ||
| 44 | $self->SUPER::draw_component(@_); | ||
| 45 | |||
| 46 | } | ||
| 47 | |||
| 48 | sub pad_top{ | ||
| 49 | return 10; | ||
| 50 | } | ||
| 51 | |||
| 52 | sub pad_right{ | ||
| 53 | return 10; | ||
| 54 | } | ||
| 55 | |||
| 56 | sub pad_left{ | ||
| 57 | return 10; | ||
| 58 | } | ||
| 59 | |||
| 60 | sub default_width{ | ||
| 61 | return 20; | ||
| 62 | } | ||
| 63 | |||
| 64 | sub vline { | ||
| 65 | my $self = shift; | ||
| 66 | my $image = shift; | ||
| 67 | my ($x,$y1,$y2) = @_; | ||
| 68 | my $fg = $self->set_pen; | ||
| 69 | |||
| 70 | $image->line($x,$y1,$x,$y2,$fg); | ||
| 71 | } | ||
| 72 | |||
| 73 | 1; | ||
| 74 | |||
| 75 | =head1 NAME | ||
| 76 | |||
| 77 | Bio::Graphics::Glyph::operon - The "polycistronic operon" glyph | ||
| 78 | |||
| 79 | =head1 SYNOPSIS | ||
| 80 | |||
| 81 | See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>. | ||
| 82 | |||
| 83 | =head1 DESCRIPTION | ||
| 84 | |||
| 85 | This glyph is used for drawing polycistronic operons. It is essentially a | ||
| 86 | "segments" glyph in which subfeatures of specific types "TSS" and "terminator" are displayed | ||
| 87 | as line+arrow and a red lollipop, respectively. Note that these are hardcoded SO types | ||
| 88 | |||
| 89 | =head2 OPTIONS | ||
| 90 | |||
| 91 | accepts standard options so far. This version does not yet allow user configuration of things like | ||
| 92 | terminator color, promoter arrow size etc. | ||
| 93 | |||
| 94 | =head1 BUGS | ||
| 95 | |||
| 96 | Please report them. | ||
| 97 | |||
| 98 | =head1 SEE ALSO | ||
| 99 | |||
| 100 | |||
| 101 | |||
| 102 | |||
| 103 | =head1 AUTHOR | ||
| 104 | |||
| 105 | Jim Hu E<lt>jimhu@tamu.eduE<gt> | ||
| 106 | |||
| 107 | Copyright (c) 2011 Texas A&M Univ. | ||
| 108 | |||
| 109 | This library is free software; you can redistribute it and/or modify | ||
| 110 | it under the same terms as Perl itself. See DISCLAIMER.txt for | ||
| 111 | disclaimers of warranty. | ||
| 112 | |||
| 113 | =cut |