Skip Menu |

This queue is for tickets about the Bio-Graphics CPAN distribution.

Report information
The Basics
Id: 85984
Status: resolved
Priority: 0/
Queue: Bio-Graphics

People
Owner: Nobody in particular
Requestors: sjpitts [...] gmail.com
Cc: randomcoder1 [...] gmail.com
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 2.37



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
Two patches to solve this problem. These patches can be applied against version 2.37 The patch to DrawTransmembrane.pm is most important and is very short. Basically loop_labels is initiatilez as a arrayref but later on it's mistaken for a hashref in some parts of the code. The second problem is in feature_draw.pl where $data->features returns an array and is mistaken for a hashref. Please consider having a look at these patches. @Steve Your code will run with these patches applied to Bio::Graphics On Sat Jun 08 10:55:25 2013, sjpitts@gmail.com wrote: Show quoted text
> 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 >
-- Your bugs , they are afraid of me.
Subject: DrawTransmembrane.pm.patch
From e5e186e52ddfd66408015a661ddc1f40c1bffa61 Mon Sep 17 00:00:00 2001 From: Petrea Corneliu Stefan <stefan@garage-coding.com> Date: Sun, 18 Aug 2013 08:04:44 +0200 Subject: [PATCH 1/1] added DrawTransmembrane fix --- lib/Bio/Graphics/DrawTransmembrane.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Bio/Graphics/DrawTransmembrane.pm b/lib/Bio/Graphics/DrawTransmembrane.pm index 260b57a..838d34d 100755 --- a/lib/Bio/Graphics/DrawTransmembrane.pm +++ b/lib/Bio/Graphics/DrawTransmembrane.pm @@ -76,7 +76,7 @@ my %DRAWOPTIONS = ( 'default' => 1}, ## labeling options 'labels' => { 'private' => 'loop_labels', - 'default' => []}, + 'default' => {}}, 'text_offset' => { 'private' => 'text_offset', 'default' => 0}, 'helix_label' => { 'private' => 'helix_label', -- 1.8.1.2
Subject: feature_draw.pl.patch
From e5e186e52ddfd66408015a661ddc1f40c1bffa61 Mon Sep 17 00:00:00 2001 From: Petrea Corneliu Stefan <stefan@garage-coding.com> Date: Sun, 18 Aug 2013 08:04:44 +0200 Subject: [PATCH 1/1] added DrawTransmembrane fix --- scripts/feature_draw.pl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/feature_draw.pl b/scripts/feature_draw.pl index e878ad0..7357adf 100755 --- a/scripts/feature_draw.pl +++ b/scripts/feature_draw.pl @@ -31,6 +31,9 @@ my @COLORS = qw(cyan blue red yellow green wheat turquoise orange); # default c my $color = 0; # position in color cycle my $data = Bio::Graphics::FeatureFile->new(-file => '-'); +use Data::Dumper; +#print Dumper [ $data->configured_types ]; +#print Dumper [ $data->features ]; # general configuration of the image here my $width = $WIDTH || $data->setting(general => 'pixels') @@ -55,7 +58,8 @@ if (!defined $start || !defined $stop) { # over is presented in alphabetic order my %types = map {$_=>1} $data->configured_types; -my @configured_types = grep {exists $data->features->{$_}} $data->configured_types; +use List::Util qw/first/; +my @configured_types = grep { my $c_type = $_; first { $c_type eq $_ } $data->features; } $data->configured_types; my @unconfigured_types = sort grep {!exists $types{$_}} $data->types; # create the segment,the panel and the arrow with tickmarks @@ -86,7 +90,13 @@ if ($BOXES) { # debugging code debugging_rectangles($gd,$boxes); } -print $gd->can('png') ? $gd->png : $gd->gif; +if($gd->can('png')) { + print STDERR "Printing png\n"; + print $gd->png; +} elsif($gd->can('gif')) { + print STDERR "Printing gif\n"; + print $gd->gif; +}; sub debugging_rectangles { my ($image,$boxes) = @_; -- 1.8.1.2
Also made a pull request with the same content on github. https://github.com/GMOD/Bio-Graphics/pull/15 On Sat Jun 08 10:55:25 2013, sjpitts@gmail.com wrote: Show quoted text
> 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 >
-- Your bugs , they are afraid of me.
GitHub pull request accepted. Thank you!