[Bioperl-l] Enabling SVG output from Bio::Graphics

Todd Harris harris at cshl.org
Wed Nov 5 12:34:01 EST 2003


Hi all - 

Formalities: for those of you who don't know me, I'm a postdoc in Lincoln's
lab. I've been lurking on the list for awhile.  It's good to be here!

Due to popular demand (that is, I needed it myself, hehe), I'm implementing
SVG output from Bio::Graphics.  To accomplish this, I've written a module
that overrides GD methods and translates them into SVG output.  In general,
this approach works fairly well although there are some methods that do not
translate well.

In order to make this happen, some fairly substantive changes need to be
made to the Bio::Graphics core. In particular, this requires removing direct
calls to GD methods from all subclasses, instead using the gd() accessor
method to fetch an image object appropriate for the type of image being
generated.

I haven't worked out all the details yet, but it should work something like
this.

1.  Bio::Graphics::Panel should accept an optional parameter
    for the image class
    
  Bio::Graphics::Panel->new(-image_class=>'SVG');

2.  The gd() method of Panel.pm creates (and acts as an accessor)
    to the image object:
  my $image_clas = $self->{image_class};
  my $gd = $existing_gd || $image_class->new($width,$height);

  $self->{gd} = $gd;

3. Glyphs and such should NOT use exported GD methods (and not 'use GD')

   gdMediumBoldFont  # no!

   my $img = $self->gd;
   $img->gdMediumBoldFont; # yes, thank you!

4. Finally, the svg() method will dump the SVG

    $img->svg();


Comments and suggestions would be most appreciated!

Thanks,

Todd Harris



More information about the Bioperl-l mailing list