[Bioperl-l] Bug in method "slice" of Bio::SimpleAlign

phil- phil- at 126.com
Sat Sep 16 13:25:29 UTC 2006


Hi there,

part of the original code of Bio::SimpleAlign, which caculate the start and end of the sliced LocatableSeq

	my $slice_seq = $seq->subseq($start, $seq_end);
	$new_seq->seq( $slice_seq );
	# start
	if ($start > 1) {
	    my $pre_start_seq = $seq->subseq(1, $start - 1);
	    $pre_start_seq =~ s/\W//g; #print "$pre_start_seq\n";
	    $new_seq->start( $seq->start + CORE::length($pre_start_seq)  );
	} else {
	    $new_seq->start( $seq->start);
	}

	# end
	$slice_seq =~ s/\W//g;
	$new_seq->end( $new_seq->start + CORE::length($slice_seq) - 1 );
 And I think there is something wrong when we have a LocatableSeq which in its negative strand.
 In my opinion it should change to this

        my $slice_seq = $seq->subseq($start, $seq_end);
        $new_seq->seq( $slice_seq );

        $slice_seq =~ s/\W//g;
        
        if ($start > 1) {
            my $pre_start_seq = $seq->subseq(1, $start - 1);
            $pre_start_seq =~ s/\W//g;
            if ($seq->strand > 0){
                $new_seq->start( $seq->start + CORE::length($pre_start_seq) );
            } else {
                $new_seq->start( $seq->end - CORE::length($pre_start_seq) - CORE::length($slice_seq) + 1);
            }
        } else {
            $new_seq->start( $seq->start);
        }
        $new_seq->end( $new_seq->start + CORE::length($slice_seq) - 1 );

Maybe my code still needs optimization, and I don't know how to distribute it to the CVS. So please help ^_^

Philip Young
GuangZhou, China
2006-9-16
   



More information about the Bioperl-l mailing list