Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Mismatches are present on first and last positions e.g. A/A and G/G. I want the program to also print the bases either side of the mismatches e.g. AT/AA and CG/GG. But if the mismatch is on the first position it prints GA/GA and if it is on the last position it prints G/G. How can I get it to not print [$i -1] if the mismatch has occured on the first position, and to not print [$i+1] if the mismatch is on the last position. Thanks for your help. ;-)ATCG AAGG
sub get_mismatches { my ($segment, $comp_segment) = @_; my @seg_mismatches; my @seg_mis; my $i; my %good_pairs = ( 'A' => 'T', 'C' => 'G', 'G' => 'C', 'T' => 'A', ); foreach (my $i =0; $i < @$segment; $i++) { if ($segment->[$i] ne $good_pairs {$comp_segment->[$i]}) { push @seg_mismatches,"$segment->[$i-1]$segment->[$i]/$com +p_segment->[$i-1]$comp_segment->[$i]\n"; push @seg_mismatches, "$segment->[$i]$segment->[$i+1]/$co +mp_segment->[$i]$comp_segment->[$i+1]\n"; push @seg_mis, "$segment->[$i-1]$segment->[$i] $segment-> +[$i]$segment->[$i+1]\n"; } } return (\@seg_mismatches, \@seg_mis); }
update (broquaint): escaped square brackets + title change (was strings)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Finding DNA string mismatches
by broquaint (Abbot) on Apr 22, 2003 at 11:03 UTC | |
(jeffa) Re: Finding DNA string mismatches
by jeffa (Bishop) on Apr 22, 2003 at 14:31 UTC | |
by BrowserUk (Patriarch) on Apr 22, 2003 at 22:16 UTC | |
Re: Finding DNA string mismatches
by Ovid (Cardinal) on Apr 22, 2003 at 15:21 UTC |