Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
$input = 'YAVSNCKFNIEDYNNIFKVMENIRKHSNKNLNDQDELNIYLGVQSSNAKR'; $l = length ($input) - 1; ### P(a), P(b), P(turn), f(i), f(i+1), f(i+2), f(i+3) ### %aa = ( A => [1.42,.83,.66,0.060,0.076,0.035,0.058], R => [.98,.93,.95,0.070,0.106,0.099,0.085], N => [.67,.89,1.56,0.161,0.083,0.191,0.091], D => [1.01,.54,1.46,0.147,0.110,0.179,0.081], C => [.70,1.19,1.19,0.149,0.050,0.117,0.128], E => [1.51,.37,.74,0.056,0.060,0.077,0.064], Q => [1.11,1.10,.98,0.074,0.098,0.037,0.098], G => [.57,.75,1.56,0.102,0.085,0.190,0.152], H => [1.00,.87,.95,0.140,0.047,0.093,0.054], I => [1.08,1.60,.47,0.043,0.034,0.013,0.056], L => [1.21,1.30,.59,0.061,0.025,0.036,0.070], K => [1.14,.74,1.01,0.055,0.115,0.072,0.095], M => [1.45,1.05,.60,0.068,0.082,0.014,0.055], F => [1.13,1.38,.60,0.059,0.041,0.065,0.065], P => [.57,.55,1.52,0.102,0.301,0.034,0.068], S => [.77,.75,1.43,0.120,0.139,0.125,0.106], T => [.83,1.19,.96,0.086,0.108,0.065,0.079], W => [1.08,1.37,.96,0.077,0.013,0.064,0.167], Y => [.69,1.47,1.14,0.082,0.065,0.114,0.125], V => [1.06,1.70,.50,0.062,0.048,0.028,0.053],); for(my $i=0; $i < $l - 4; $i++) { my $col = 0; # reference to hashmap column 1, P(a) $orf = substr($input,$i,6); @fra = split('', $orf), "\t"; $count = count(@fra), "\t"; #characters ge 1 print $orf, " ", $count, "\n"; if ($count ge 4) { for (my $j=$i+3; $j le $l - 3; $j++) { print my $frame = substr($input, $j, 4);# print " "; print my $alpha4 = average ($frame, $col), "\n"; if ($alpha4 lt 1.00) {$j = $l}; }; print "\n"; } } exit; sub count { my $c = 0; foreach (@_) { my $p = $aa{$_}[0]; if ($p ge 1.00) {$c++}; } return $c; } sub average { my ($frame, $col) = @_; my $a = 0; @seq = split ('', $frame); foreach $_ (@seq) { $a += $aa{$_}[$col]; } return $a/(length($frame)); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Beginner issues!
by kcott (Archbishop) on Nov 16, 2010 at 05:41 UTC | |
|
Re: Beginner issues!
by CountZero (Bishop) on Nov 16, 2010 at 07:02 UTC | |
|
Re: Beginner issues!
by ikegami (Patriarch) on Nov 16, 2010 at 05:41 UTC |