[Bioperl-l] Re: sub_Location in Bio::Location::Simple?

Jason Stajich jason@cgt.mc.duke.edu
Tue, 28 May 2002 11:46:54 -0400 (EDT)


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


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
>

-- 
Jason Stajich
Duke University
jason at cgt.mc.duke.edu