[Bioperl-l] [Bio::Graphics::Panel] code reference cannot pass to -link, why?

Xianjun Dong Xianjun.Dong at bccs.uib.no
Wed Jul 8 11:04:15 EDT 2009


Hi, Scott

Thanks for your help to my previous question about background layer. It 
works well!

Now, I have another question regarding the -link function in imagemap. I 
post to Bioperl mailist. It seems to detail to get much attention. I 
followed the code in the Bio::Graphics POD, but it does not work. Could 
you pls take a look?

Thanks again

Xianjun


Xianjun Dong wrote:
> Hi,
>
> I have a problem while using the -link in Bio::Graphics (version 1.96):
>
> As the POD of Bio::Graphics described 
> (http://search.cpan.org/~lds/Bio-Graphics-1.96/lib/Bio/Graphics/Panel.pm#Creating_Imagemaps), 
>
>
> link format like:
>
>  -link => 'http://www.google.com/search?q=$description'
>
>
> works well in my code, but the format like
>
>  -link => sub {
>         my ($feature,$panel) = @_;
>         my $type = $feature->primary_tag;
>         my $name = $feature->display_name;
>         if ($primary_tag eq 'clone') {
>            return "http://www.google.com/search?q=$name";
>         } else {
>            return "http://www.yahoo.com/search?p=$name";
>         }
>
>
> does not output image map as expected.
>
> Here I attached a simple code as example for anyone who is willing to 
> test for me:
>
>        #!/usr/bin/perl
>        use strict;
>        use Bio::Graphics;
>        use Bio::Graphics::Feature;
>        my $ftr= 'Bio::Graphics::Feature';
>                # processed_transcript
>        my $trans1 =
>        
> $ftr->new(-start=>50,-end=>10,-display_name=>'ZK154.1',-type=>'UTR');
>        my $trans2 =
>        
> $ftr->new(-start=>100,-end=>50,-display_name=>'ZK154.2',-type=>'CDS');
>        my $trans3 =
>        
> $ftr->new(-start=>350,-end=>225,-display_name=>'ZK154.3',-type=>'CDS',
>        -source=>'a');
>        my $trans4 =
>        
> $ftr->new(-start=>700,-end=>650,-display_name=>'ZK154.4',-type=>'UTR');
>        my @trans = ($trans1,$trans2,$trans3,$trans4);
>
>        my $panel= Bio::Graphics::Panel->new(-start =>0,-length=>1050);
>
>        $panel->add_track(\@trans,
>                  -glyph   => 'transcript2',
>                                                  # This works well!
>                          #-link =>
>        'http://www.google.com/search?q=$name',                         
>                          # while, the following code does not work as
>        expected.
>                          -link => sub {
>                                      my ($feature,$panel) = @_;
>                                      my $type = $feature->primary_tag;
>                                      my $name = $feature->display_name;
>                                      if ($type eq 'CDS') {
>                                         return
>        "http://www.google.com/search?q=$name";
>                                      } else {
>                                         return
>        "http://www.yahoo.com/search?p=$name";
>                                      }
>                                 }
>                          );
>        my $map = $panel->create_web_map("mapname");
>        print $map;
>        $panel->finished();
>
> In my test (Bioperl 1.6.0), its output is:
>
>        <map name="mapname" id="mapname">
>        <area shape="rect" coords="11,0,58,7"
>        href="http://www.yahoo.com/search?p="  />
>        <area shape="rect" coords="57,10,115,17"
>        href="http://www.yahoo.com/search?p="  />
>        <area shape="rect" coords="257,0,401,7"
>        href="http://www.yahoo.com/search?p="  />
>        <area shape="rect" coords="743,0,801,7"
>        href="http://www.yahoo.com/search?p="  />
>        </map>
>
>
> It seems $feature->primary_tag returns 'track' (I don't know where 
> this come from...), but not the type of features.  Anyone has clue for 
> this problem?
>
> Thanks
>

-- 
==========================================
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
==========================================




More information about the Bioperl-l mailing list