[Bioperl-l] Re: sub_Location in Bio::Location::Simple?
Heikki Lehvaslaiho
heikki@ebi.ac.uk
Mon, 01 Jul 2002 16:03:43 +0100
Charles,
I think silence indicates indifference/inability to see the need of the
addition/inability to to see any reason to object. You have the need, so do
the additions and let's see if someone complains.
-Heikki
Charles Tilford wrote:
> I'm not sure what the Bioperl-culturally-appropriate-interpretation of
> "null comment" is - should I add each_location() to the appropriate
> modules? Uncertain whether the lack of response indicates quiet
> satisfaction or stunned shock...
>
> -CAT
>
> Charles Tilford wrote:
>
>>Jason Stajich wrote:
>>
>>
>>>I'd rather create a new method, something like:
>>>each_Location().
>>>
>>>This can be implemented as a recursive method to handle the case when
>>>split locations contain other split locations.
>>>
>>>I don't want to make Simple locations explictly act like Split locations
>>>with a single loc since that defeats the purpose of separating the
>>>interfaces.
>>>
>>>Other people may have input?
>>>-j
>>>
>>
>>I'm happy with a new method. How about these changes then?
>>
>>Bio::Location::Split
>>
>>sub each_Location {
>> my ($self, $order) = @_;
>> my @locs = ();
>> foreach my $subloc ($self->sub_Location($order)) {
>> # Recursively check to get hierarchical split locations:
>> push @locs, $subloc->each_Location($order);
>> }
>> return @locs;
>>}
>>
>>Bio::Location::Simple
>>
>>sub each_Location {
>> my ($self) = @_;
>> return $self;
>>}
>>
>>Bio::LocationI
>>
>>sub each_Location {
>> my ($self,@args) = @_;
>> $self->throw_not_implemented();
>> return undef;
>>}
>>
>>-Charles
>>
>>
>>>On Tue, 28 May 2002, Charles Tilford wrote:
>>>
>>>
>>>
>>>
>>>>Hi Jason,
>>>>
>>>>Would you mind if I added a sub_Location method in
>>>>Bio::Location::Simple? It would look like this:
>>>>
>>>>=head2 sub_Location
>>>>
>>>> Title : sub_Location
>>>> Usage : $loc = $loc->sub_Location();
>>>> Function: compatibility method to allow this single method to get
>>>>locations from either Simple or Split locations.
>>>> Returns : the Bio::Location::Simple object itself
>>>> Args :
>>>>
>>>>=cut
>>>>
>>>>sub start {
>>>> my ($self) = @_;
>>>> return $self;
>>>>}
>>>>
>>>>I find myself doing this frequently, to grab all the locations in a
>>>>given feature:
>>>>
>>>> my $fLoc = $feat->location;
>>>> my $locs = ($fLoc =~ /Split/) ? [$fLoc->sub_Location()] : [$fLoc];
>>>>
>>>>If ::Simple had a sub_Location method, then I could just say:
>>>>
>>>>my @locs = $feat->location->sub_Location();
>>>>
>>>>Not sure if I am overlooking a gotcha here...
>>>>
>>>>-Charles
>>>
>
--
______ _/ _/_____________________________________________________
_/ _/ http://www.ebi.ac.uk/mutations/
_/ _/ _/ Heikki Lehvaslaiho heikki@ebi.ac.uk
_/_/_/_/_/ EMBL Outstation, European Bioinformatics Institute
_/ _/ _/ Wellcome Trust Genome Campus, Hinxton
_/ _/ _/ Cambs. CB10 1SD, United Kingdom
_/ Phone: +44 (0)1223 494 644 FAX: +44 (0)1223 494 468
___ _/_/_/_/_/________________________________________________________