Subject: | bug in Bio::Graphics::DrawTransmembrane constructor/defaults |
Date: | Sat, 8 Jun 2013 07:55:04 -0700 |
To: | bug-Bio-Graphics [...] rt.cpan.org |
From: | Steven Pitts <sjpitts [...] gmail.com> |
While walking through the demo code in the POD documentation for Bio::Graphics::DrawTransmembrane, I discovered a bug that makes even the demo code throw an error and output an empty image file.
The issue is that in the hash %DRAWOPTIONS, the default value set via the 'labels' key (which ultimately sets the default value of the Bio::Graphics::DrawTransmembrane object's 'loop_labels' property) is an array reference rather than a hash reference. All other methods dereference this as a hash ref so it renders subsequent method calls nonfunctional with 'Not a HASH reference...' errors thrown.
it should be the case that $DRAWOPTIONS{'labels'}{'default'} = {}, not $DRAWOPTIONS{'labels'}{'default'} = [] as it is currently coded.
Explicitly setting the loop_labels property of a Bio::Graphics::DrawTransmembrane object to a hash ref prior to calling the png method will rescue the code (try the code below with and without the ### commented portion to verify the bug).
use Bio::Graphics::DrawTransmembrane;
my @topology = (20,45,59,70,86,109,145,168,194,220);
## Simple use - -topology is the only option that is required
my $im = Bio::Graphics::DrawTransmembrane->new( -title => 'This is a cartoon displaying transmembrane helices.', -topology => \@topology);
### without this perl throws
### Not a HASH reference at /Library/Perl/5.12/Bio/Graphics/DrawTransmembrane.pm line 125.
### $im->{loop_labels} = {};
## Now write the image to a .png file
open(OUTPUT, ">output.png");
binmode OUTPUT;
print OUTPUT $im->png;
close OUTPUT;
Thanks for making the package available.
Cheers,
Steve Pitts