Hi all, I'm doing an assignment that requires I shuffle a DNA sequence, then score the "mutations" according to a set of rules. I have come up with the below code and it is obviously not working (gives really odd results, like -2-4-400-200...etc) I'm hoping I just did something silly. My intent was to create a foreach loop that would use the subroutine I have that has a hash that creates numeric values based on evaluating the keys (hopefully that makes sense). Here is the code:
my $score; foreach(0 .. length($string) - 1){ my $s = substr($string, $_, 1); my $m = substr($shuf_seq, $_, 1); $score = scoring($s, $m); $score += $score; print $score; } print "\nThis is the total mutation score: $score \n"; #sub to calculate the scoring of mutations #If purine --> purine: -1 #If pyrimidine --> pyrimidine: -1 #If purine --> pyrimidine (or vice versa): -2 #If no change: 0 sub scoring{ my ($a, $b) = sort @_; my %scores; $scores{'A'}{'G'} = -1; $scores{'A'}{'T'} = -2; $scores{'A'}{'C'} = -2; $scores{'G'}{'T'} = -2; $scores{'C'}{'G'} = -2; $scores{'C'}{'T'} = -1; $scores{'A'}{'A'} = +0; $scores{'T'}{'T'} = +0; $scores{'C'}{'C'} = +0; $scores{'G'}{'G'} = +0; return $scores{$a}{$b}; }
In reply to Bioinformatics - Scoring DNA mutations by allsop_5
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |