[Bioperl-l] background layer is not supported in Bioperl 1.6 for Bio::Graphics::Glyph

Xianjun Dong Xianjun.Dong at bccs.uib.no
Fri Jun 12 16:38:50 EDT 2009


I am not sure this is the right place I can get help.

I've suffered by a problem for several days: I want to highlight parts 
of regions in my track, using a different background color. To do that, 
I defined a glyph named "background", based on the 
'Bio::Graphics::Glyph::generic' module. I override the draw_component() 
method, by adding code like below:


# the script is pasted at the end

This will draw a rectangle with top=0, bottom=$gd->height. I made the 
highlight regions into a list of features, and add_track with 
-glyph=>'background'. (see the following script, test.pl) This really 
works as I expect, which will add a colored block at background of all 
tracks in a panel (including the ruler arrow). You can see the output 
image in attached file "test.bioperl1.2.3.png"

Now, the problem comes: when I switch to Bioperl 1.5 (or 1.6), it does 
not work. Well, it works, but the highlight part only shrink to a low 
height, instead of covering all tracks in the panel. I also attached the 
output here, see the file "test.bioperl1.6.png".

I tried to think about the reason, the 'background' module is based on 
the generic module. What can cause the difference? Is it because 
$gd->height is different, or the tracks followed with 'background' track 
can not draw from the first position?

Well. I can stick to use Bioperl 1.2.3 to avoid the problem. ("Smart 
person solve problem, wise person avoid problem"...) But another problem 
is coming: Bio::Graphics in Bioperl 1.2.3 does not support 
$panel->create_web_map() function, which means I have to use some higher 
version if I want to create web map for my graphics, but then I have to 
give up using highlight background.

OK. It's long enough for my first-time submission here. Hope someone can 
throw me some clue.

Thanks ahead!!


==================== test.pl =======================
use strict;
use lib "$ENV{HOME}/lib";
use Bio::Graphics;
use Bio::Graphics::Feature;
my $ftr= 'Bio::Graphics::Feature';
# processed_transcript
my $trans1 = 
my $trans2 = $ftr->new(-start=>100,-end=>50,-name=>'ZK154.2',-type=>'CDS');
my $trans3 = 
my $trans4 = 
my $trans5 = 
my $trans  = 

# hightlight
my $trans31 = 
my $trans41 = 
my $panel= Bio::Graphics::Panel->new(-width=>1200,
                                             -start =>0,

# the following track works as I expected in bioperl 1.2.3, but not in 
1.5 and 1.6
          -glyph   => 'background',
                  -block_bgcolor => sub{return (shift->source eq 


          -glyph   => 'transcript2', # 'transcript2', #process_5utr',
                  -fgcolor => 'darkred',
                  -bgcolor => 'darkred',
                  -title => '$source',
                  -link => 
'http://www.ensembl.org/Homo_sapiens/transview?transcript=$name',  #EnsEMBL
print $panel->png;

# the following part works in bioperl 1.5 and 1.6, but not work in 
Bioperl 1.2.3
my $map = $panel->create_web_map("image");


==================== background.pm =======================
package Bio::Graphics::Glyph::background;
use strict;
use base 'Bio::Graphics::Glyph::generic';
sub pad_top{
  return 0;

sub draw_component {
  my $self = shift;
  my ($gd,$dx,$dy) = @_;
  my ($left,$top,$right,$bottom) = $self->bounds($dx,$dy);
  # draw an arrow to indicate the direction of transcript
  my $color = $self->option('block_bgcolor') || '#cccccc';

Xianjun Dong
PhD student, Lenhard group
Computational Biology Unit
Bergen Center for Computational Science
University of Bergen
Hoyteknologisenteret, Thormohlensgate 55
N-5008 Bergen, Norway
E-mail: xianjun.dong at bccs.uib.no
Tel.: +47 555 84022
Fax : +47 555 84295

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.bioperl1.2.3.png
Type: image/png
Size: 2789 bytes
Desc: not available
URL: <http://lists.open-bio.org/pipermail/bioperl-l/attachments/20090612/9cdc621a/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.bioperl1.6.png
Type: image/png
Size: 2365 bytes
Desc: not available
URL: <http://lists.open-bio.org/pipermail/bioperl-l/attachments/20090612/9cdc621a/attachment-0001.png>

More information about the Bioperl-l mailing list