[Bioperl-l] Use of uninitialized value in length at Bio/DB/SeqFeature/Store/DBI/mysql.pm line 1062

Jason Stajich jason at bioperl.org
Sun Mar 27 13:28:04 EDT 2011


Dan - not sure why you would need to do this as length on an undef 
should still return false (an undef).

$ perl -e '$g=""; if( length($g)) { print "yes" } else { print "no"} 
print "\n"'
no
$ perl -e '$g=undef; if( length($g)) { print "yes" } else { print "no"} 
print "\n"'
no

Also, having no 'source' is probably not proper GFF3.

BTW bugzilla is dead so the bug that you refer to is here
   http://redmine.open-bio.org/issues/2899
I've assigned the bug to Lincoln to help figure out what should be done 
with it.

Thanks,
jason

Dan Bolser wrote:
> Hi all,
>
> I'm not sure why, but the code in Bio/DB/SeqFeature/Store/DBI/mysql.pm uses:
>      if (length $source_tag) {
>
> within the '_types_sql' function to test if $source_tag is defined
> (and has a length). This obviously fails when $source_tag it isn't
> defined, and I see the above error message from my script when I call
> the 'features' function (as shown below).
>
> > From tests (thanks to rbuels in #bioperl) it seems the value of $type
> is simply 'fwd link intensity', so:
>        ($primary_tag,$source_tag) = split ':',$type,2;
>
> on line 1047 leaves $source_tag undefined.
>
> Here is my proposed fix:
>
> diff --git a/Bio/DB/SeqFeature/Store/DBI/mysql.pm b/Bio/DB/SeqFeature/Sto
> index 00103c2..dfc70c0 100644
> --- a/Bio/DB/SeqFeature/Store/DBI/mysql.pm
> +++ b/Bio/DB/SeqFeature/Store/DBI/mysql.pm
> @@ -1057,8 +1057,8 @@ sub _types_sql {
>         ($primary_tag,$source_tag) = split ':',$type,2;
>       }
>
> -    if (length $source_tag) {
> -      if (length($primary_tag)) {
> +    if (defined $source_tag&&  length $source_tag) {
> +      if (defined $primary_tag&&  length($primary_tag)) {
>           push @matches,"tl.tag=?";
>           push @args,"$primary_tag:$source_tag";
>         }
>
>
> which seems to work. I'd write some tests, but an old bug that I can't
> track down prevents me from running tests on this package
> (http://bugzilla.open-bio.org/show_bug.cgi?id=2899).
>
> Cheers,
> Dan.
>
>
> Here are some snippets of code to give context:
>
> my $intensities = Bio::DB::SeqFeature::Store->
>    new( -adaptor =>  'DBI::mysql',
> 	-dsn =>  'db:mysql.server.ac.uk',
> 	-user =>  'me',
> 	-pass =>  'secret',
>         -verbose =>  $verbose,
>       );
>
> my @fwd_intensity = $intensities->
>      features( -seqid =>  'some-id', -type =>  'fwd link intensity',
>                -start =>  10,
>                -end   =>  200,
>      );
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l

-- 
Jason Stajich
jason at bioperl.org
http://bioperl.org/wiki



More information about the Bioperl-l mailing list