[Bioperl-l] Bio::Cluster

Andrew Macgregor andrew@anatomy.otago.ac.nz
Wed, 07 Aug 2002 12:20:44 +1200


Thanks Hilmar,

I think I must have figured that for some design reason that I wasn't aware
of, that nothing should return undef, in the same fashion as primary_id().
But I was obviously off beam there, so I'll make the appropriate changes.

Cheers, Andrew.



Hilmar Lapp wrote:

> Right. The thing with PrimarySeq::primary_id() is that that method
> must not return undef, and is supposed to return a unique ID. The
> memory location serves as the last resort in this case.
> 
> -hilmar
> 
> On Tuesday, August 6, 2002, at 03:08  PM, Andrew Macgregor wrote:
> 
>> Hilmar Lapp wrote:
>> 
>>> is there a
>>> reason you don't want to return undef for a slot that's undef?
>>> 
>> Hi Hilmar,
>> 
>> No there's not really a reason I do this. When I was putting this
>> together I
>> based it on Seq.pm. So I looked at code like this:
>> 
>> sub primary_id {
>>    my ($obj,$value) = @_;
>> 
>>    if( defined $value) {
>>       $obj->{'primary_id'} = $value;
>>     }
>>    if( ! exists $obj->{'primary_id'} ) {
>>        return "$obj";
>>    }
>>    return $obj->{'primary_id'};
>> }
>> 
>> 
>> And basically followed that pattern. When something isn't present I
>> return
>> the stringified reference. I thought I might be breaking something
>> in the
>> bigger picture if I did not.
>> 
>> I guess looking at this more closely this is only used for
>> primary_id. What
>> purpose exactly does ' return "$obj" ' serve here? I guess my code
>> should
>> just be something like:
>> 
>> sub gene {
>>    my ($obj,$value) = @_;
>> 
>>    if( defined $value) {
>>       $obj->{'gene'} = $value;
>>     }
>>    return $obj->{'gene'};
>> }
>> 
>> 
>> Which cuts out:
>> 
>>    if( ! exists $obj->{'gene'} ) {
>>        return "$obj";
>>    }
>> 
>> 
>> Does that sound right?
>> 
>> Cheers, Andrew.
>> 
>> 
>> 
>> 
> --
> -------------------------------------------------------------
> Hilmar Lapp                            email: lapp at gnf.org
> GNF, San Diego, Ca. 92121              phone: +1-858-812-1757
> -------------------------------------------------------------
>