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

Roy Chaudhuri roy.chaudhuri at gmail.com
Sun Mar 27 18:26:55 UTC 2011


Hi Dan,

I think your problem is that you are using the outdated -w flag, which 
reports warnings from inside modules that may not have been designed 
with warnings in mind. The "use warnings" pragma is preferred. See:
http://perldoc.perl.org/perllexwarn.html#What%27s-wrong-with-*-w*-and-$^W

Cheers,
Roy.

On 27/03/2011 18:55, Dan Bolser wrote:
> On 27 March 2011 18:28, Jason Stajich<jason at bioperl.org>  wrote:
>> 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
>
> Doesn't the latter spew a warning? (The output before / after my 'bug
> fix' is the same, I just don't see 100s of warnings about undefined
> values).
>
>
>> Also, having no 'source' is probably not proper GFF3.
>
> I'm quite sure it is, but by GFF does have a source. I'm just calling
> 'features' with only a feature type and not a feature type and a
> source (because I only care about source). My call is pretty similar
> to the example here:
>
> http://search.cpan.org/~cjfields/BioPerl-1.6.0/Bio/DB/SeqFeature/Store.pm#features
>
>   @features = $db->features(-seqid=>'Chr1',-start=>5000,-end=>6000,-types=>'mRNA');
>
>
>> 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
>
> Cheers Jason,
> Dan.
>
>
>> 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
>>
>>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l




More information about the Bioperl-l mailing list