[Bioperl-l] PROPOSED new method Bio::Range->offsetStranded

Cook, Malcolm MEC at stowers-institute.org
Tue Jan 9 18:05:09 EST 2007


Hi,

I'd like to commit changes to Bio::RangeI which defined offsetStranded
to allows the following tests to pass in Bio/Range.t

$r = Bio::Range->new(-start => 30, -end => 40, -strand => -1);
ok ($r->offsetStranded(-5,10)->toString, '(20, 45) strand=-1');
ok ($r->offsetStranded(+5,-10)->toString, '(30, 40) strand=-1');
$r->strand(1);
ok ($r->offsetStranded(-5,10)->toString, '(25, 50) strand=1');
ok ($r->offsetStranded(+5,-10)->toString, '(30, 40) strand=1');


Here's the implementation.

=head2 offsetStranded

    Title    : offsetStranded
    Usage    : $rnge->ofsetStranded($fiveprime_offset,
$threeprime_offset)
    Function : destructively modifies RangeI implementing object to
               offset its start and stop coordinates by values
$fiveprime_offset and
               $threeprime_offset (positive values being in the strand
direction).
    Args     : two integer offsets: $fiveprime_offset and
$threeprime_offset
    Returns  : $self, offset accordingly.

=cut

sub offsetStranded {
  my ($self, $offset_fiveprime, $offset_threeprime) = @_;
  my ($offset_start, $offset_end) = $self->strand() eq -1 ? (-
$offset_threeprime, - $offset_fiveprime) : ($offset_fiveprime,
$offset_threeprime);
  $self->start($self->start + $offset_start);
  $self->end($self->end + $offset_end);
  return $self;
};


I'll commit tomorrow unless I'm told 'that would be a mistake'.

Cheers,

--Malcolm



More information about the Bioperl-l mailing list