Hi monks,
I am trying to turn a nice bit of code into a space-saving sub-routine. Anyway,
all it wants to do is compare two DNA strings at every position to see if
they are correctly paired (where A-T and C-G are correct pairings).
This code worked lovely as a non-subroutine and i think the problem lies with
passing more than one array into the sub by reference.
Hope someone can correct my stupidity ;->
my $mismatch = get_mismatches (\@dna, \@complement);
sub get_mismatches {
my ($dna, $complement) = @_;
print "<P>TESTING TESTING TESTING SEGMENT::::: @$
+dna <P> COMP::::::: @$complement<P><P>";
my $i;
my %good_pairs = (
'A' => 'T',
'C' => 'G',
'G' => 'C',
'T' => 'A',
);
foreach (my $i =0; $i < @$dna; $i++) {
if ($dna[$i] ne $good_pairs {$complement[$i]}) {
print "SUB - MISMATCH: $dna[$i-1]$dna[$i]/$complement[$i-
+1]$complement[$i]\n";
push @seg_mismatches,"$dna[$i-1]$dna[$i]/$complement[$i-1
+]$complement[$i]\n";
print "SUB - MISMATCH: $dna[$i]$dna[$i+1]/$complement[$i]
+$complement[$i+1]\n";
push @seg_mismatches, "$dna[$i]$dna[$i+1]/$complement[$i]
+$complement[$i+1]\n";
push @seg_mis, "$dna[$i-1]$dna[$i] $dna[$i]$dna[$i+1]\n";
}
}
return (@seg_mismatches);
}
20030325 Edit by Corion: Changed title
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.