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

Peili Zhang peili at morgan.harvard.edu
Thu Jun 26 13:10:26 EDT 2003


Hi,

>>> 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);
>
>this changes the $sl object. does it change $loc, $sf->location, and the 
>Bio::Seq object ($seq) hosting $sf? seems to me $sf is a separate object from 
>$seq. so is $loc from $sf, and $sl from $loc. it seems to me that even if I can 
>change the derived objects any way I want, the objects I'm deriving from just 
>stay intact. this is why I asked my question at the first place. do I get it 
>wrong completely?
>
>thanks,
>Peili

hmm, I did a test on this, it turned out the Bio::Seq object did get mutated if 
I got its feature location objects and changed the location objects by 
themselves. the pass-by-reference mechanism skipped my brain...

>>         }
>>#     }
>>#     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