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

Marc Logghe Marc.Logghe at devgen.com
Wed Jun 25 23:31:02 EDT 2003


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;
    if ( $loc->can('sub_Location') ) {
        foreach my $sl ( $loc->sub_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


More information about the Bioperl-l mailing list