[Bioperl-l] Bio::Graphics and HTML

Bernhard Schmalhofer Bernhard.Schmalhofer at biomax.de
Mon Feb 3 17:22:51 EST 2003


William Boileau schrieb:
> It's said in the Bio::Graphics HOWTO that we can generate HTML image maps...
> But I can't find how anywhere... :\
> So does anyone have nay idea ?
> 


Hi,

the methods Bio::Graphics::Panel::boxes() can be used for creating image 
maps. Here is a snippet of code, we use for going from an overview over 
a contig sequence to detailed information:

print "<map name='contig_detail'>\n";
# $panel is a Bio::Graphics::Panel object
# boxes returns an array of [ $feature, $x1, $y1, $x1, $y2 ]
foreach ( $panel->boxes() )
{
   my $feature = $_->[0];
   my $coords  = join( ',', @{$_}[1..4] );

   my ( $alt, $href );
   if ( ref( $feature ) eq 'Bio::SeqFeature::Generic' )
   {
     ( $alt ) = $feature->each_tag_value( 'id' ) if $feature->has_tag( 
'id' );
     my $primary_tag = $feature->primary_tag();
     if ( $primary_tag eq 'ORF' )
     {
       $href = '../orf/index.mhtml?' . enurl( { orf_code => $alt, tab => 
'orf' } );
     }
     elsif ( $primary_tag eq 'BAC end' )
     {
       # No report for BAC ends yet
     }
     elsif ( $primary_tag eq 'genetic element' )
     {
       # No report for genetic elements yet
     }
   }
   else
   {
     die Dumper( $feature );
   }
   if ( $href )
   {
     print qq{    <area shape='rect' coords='$coords' href='$href' 
alt='$alt'>\n};
   }
}
print "</map>\n";
<img src='link_to_image.png' alt='contig' usemap='#contig_detail'/>


CU, Bernhard

-
*************************************************
Bernhard Schmalhofer
Senior Developer

Biomax Informatics AG
Lochhamer Str. 11
82152 Martinsried, Germany

Tel:    +49 89 89 55 74 - 839
Fax:    +49 89 89 55 74 - 25
PGP:    https://ssl.biomax.de/pgp/
Email:  mailto:Bernhard.Schmalhofer at biomax.de
Web:    http://www.biomax.de
*************************************************



More information about the Bioperl-l mailing list