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

Chris Fields cjfields at illinois.edu
Sun Mar 27 16:13:14 EDT 2011


On Mar 27, 2011, at 12:55 PM, 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).

Only with later versions of perl (I think perl 5.12).

>> 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');

I think Jason is inferring that the GFF3 is invalid from your statement below re: $source_tag not being defined, which to me means the source attribute for the feature is not defined.

Note: b/c something works with SF::Store does NOT mean the source is proper GFF3; it is quite possible to have invalid GFF3 loaded into the database w/o a hiccup.  I think the loader assumes the data loaded has already been validated; IIRC there is very little validation done on GFF3 loaded into SF::Store, particularly the 'type'.

chris

>> 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