[Bioperl-l] true inserts into a SimpleAlign

Chris Fields cjfields at illinois.edu
Tue Feb 3 20:31:08 EST 2009


If it passes all tests (not just SimpleAlign.t) I don't see a  
problem.  BTW passed for me, but I didn't run everything.

chris

On Feb 3, 2009, at 6:06 PM, Mark A. Jensen wrote:

> Folks-
>
> I was desiring to make a true insertion of a LocatableSeq into a  
> SimpleAlign,
> rather than just adding it to the end as
> $aln->add_seq($lseq)
> would do. This:
> $aln->add_seq($lseq,$order)
> currently stomps on whatever is stored at $order in the index. The  
> patch at
> the bottom of the post allows a true insertion (if something exists  
> at index
> location $order, the minimum number of entries from that point on  
> are moved
> down to make room.)
>
> Might be useful for others. All t/Align/SimpleAlign.t tests pass.  
> Lemme know-
>
> Mark
>
> ---
>
> Index: SimpleAlign.pm
> ===================================================================
> --- SimpleAlign.pm (revision 15496)
> +++ SimpleAlign.pm (working copy)
> @@ -304,8 +304,22 @@
>      else {
>   $self->debug( "Assigning $name to $order\n");
>
> - $self->{'_order'}->{$order} = $name;
> + my $ordh = $self->{'_order'};
> + if ($ordh->{$order}) {
> +     # make space to insert
> +     # $c->() returns (in reverse order) the first subsequence
> +     # of consecutive integers; i.e., $c->(1,2,3,5,6,7) returns
> +     # (3,2,1), and $c->(2,4,5) returns (2).
> +     my $c;
> +     $c = sub { return (($_[1]-$_[0] == 1) ? ($c->(@_[1..$#_]), 
> $_[0]) : $_[0]); };
> +     map {
> +  $ordh->{$_+1} = $ordh->{$_}
> +     } $c->(sort {$a <=> $b} grep {$_ >= $order} keys %{$ordh});
>
> + }
> + $ordh->{$order} = $name;
> +
> +
>   unless( exists( $self->{'_start_end_lists'}->{$id})) {
>       $self->{'_start_end_lists'}->{$id} = [];
>   }
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l



More information about the Bioperl-l mailing list