[Bioperl-l] Re: sub_Location in Bio::Location::Simple?
Charles Tilford
charles.tilford@bms.com
Mon, 01 Jul 2002 08:54:32 -0400
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
--
Charles Tilford, Bioinformatics-Applied Genomics
Bristol-Myers Squibb PRI, Hopewell 3A039
P.O. Box 5400, Princeton, NJ 08543-5400, (609) 818-3213
charles.tilford@bms.com