[Bioperl-l] change the location coordinates of a Bio::SeqFeat ureI object

Jason Stajich jason at cgt.duhs.duke.edu
Wed Jun 25 18:05:19 EDT 2003


You might also look at Bio::Coordinate::GeneMapper as well depending on
how complicated you want to do things.  If it is as simple as you
describe, code below should do just fine.

We separated Locations from SeqFeature a while a go so you can whole
replace the location object for a feature
$sf->location( $newlocation )
or manipulate the fields directly, etc...
$sf->location->start($newstart);

See below for code shortcut too.

On Wed, 25 Jun 2003, Marc Logghe wrote:

> Hi,
>
>
>
> >
> > I'm trying to do some coordinate translation for the locations of
> > SeqFeatures in a Bio::Seq object. my plan to achieve this is to first
> > flush out all seq features of the Bio::Seq object, and then
> > add back the
> Actually, you don't have to do this, at least I think so, correct me if I'm
> wrong. You just can loop over the features and adjust the coordinates of the
> feature objects. You getting back references to (feature) objects after all
> that are attribute values of sequence objects.
> > array of features with the new coordinates.
> >
> > for the features with simple locations (ie start..end), I can use
> > $feature->start($new_start) and $feature->end($new_end) to set the
> > locations to new coordinates, but how can I make such changes for the
> > seq features which have split locations? for instance, an mRNA feature
> > has a join location like join(10..20, 30..40, 50..60), its
> > location will
> > be a Bio::Location::SplitLocationI object. I can retrieve the
> > sub-locations through the sub_Location() method. I need to mutate the
> > location of this mRNA feature  to be join(1010..1020, 1030..1040,
> > 1050..1060). how do I do this?
> First check what kind of feature you have to deal wiht: split or not split
> and adjust appropriately. This sub should do the job when passed a feature
> object (reference).
> sub adjust_location {
>     my ( $sf, $cutoff ) = @_;
>     my $loc = $sf->location;

with newer bioperl code you can in fact replace this with
#     if ( $loc->can('sub_Location') ) {
#         foreach my $sl ( $loc->sub_Location ) {
     foreach my $sl ( $loc->each_Location ) {

             my $newstart = $sl->start + $cutoff;
             my $newend   = $sl->end + $cutoff;
             $sl->start($newstart), $sl->end($newend);
         }
#     }
#     else {
#         my $newstart = $loc->start + $cutoff;
#         my $newend   = $loc->end + $cutoff;
#        $loc->start($newstart), $loc->end($newend);
#     }
>
> }
> HTH,
> Marc
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>

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


More information about the Bioperl-l mailing list