zing has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use Time::HiRes qw(usleep nanosleep); %nuc = ( F => [qw( .0001 .0001 .0001 .0000 .0000 .0000 .0000 .0001 .0002 .0008 + .0006 .0000 .0004 .9944 .0000 .0000 .0001 .0003 .0028 .0000)], T => [qw( .0022 .0002 .0013 .0004 .0001 .0003 .0002 .0002 .0001 .0011 + .0002 .0008 .0006 .0001 .0005 .0032 .9874 .0000 .0002 .0009)], N => [qw( .0004 .0001 .9867 .0036 .0000 .0004 .0006 .0006 .0021 .0003 + .0001 .0013 .0000 .0001 .0002 .0020 .0009 .0001 .0004 .0001)], V => [qw( .0013 .0002 .0001 .0001 .0003 .0002 .0002 .0003 .0003 .0057 + .0011 .0001 .0017 .0001 .0003 .0002 .0010 .0000 .0002 .9866)], K => [qw( .0002 .0037 .0025 .0006 .0000 .0012 .0007 .0002 .0002 .0004 + .0001 .9858 .0020 .0000 .0003 .0008 .0011 .0000 .0001 .0001)], E => [qw( .0010 .0000 .0007 .0056 .0000 .0035 .9865 .0004 .0002 .0003 + .0001 .0004 .0001 .0000 .0003 .0004 .0002 .0000 .0001 .0002)], Y => [qw( .0001 .0000 .0003 .0000 .0003 .0000 .0001 .0000 .0004 .0001 + .0001 .0000 .0000 .0021 .0000 .0001 .0001 .0002 .9960 .0001)], Q => [qw( .0003 .0010 .0004 .0005 .0000 .9901 .0027 .0001 .0024 .0001 + .0003 .0006 .0004 .0000 .0006 .0002 .0002 .0000 .0000 .0001)], I => [qw( .0002 .0002 .0003 .0001 .0002 .0001 .0002 .0000 .0000 .9915 + .0009 .0002 .0012 .0007 .0000 .0001 .0007 .0000 .0001 .0033)], C => [qw( .0001 .0001 .0000 .0000 .9987 .0000 .0000 .0000 .0001 .0001 + .0000 .0000 .0000 .0000 .0001 .0005 .0001 .0000 .0000 .0002)], L => [qw( .0003 .0001 .0003 .0000 .0000 .0006 .0001 .0001 .0004 .0022 + .9871 .0002 .0045 .0013 .0003 .0001 .0003 .0004 .0002 .0015)], M => [qw( .0001 .0001 .0000 .0000 .0000 .0002 .0000 .0000 .0000 .0005 + .0009 .0005 .9968 .0001 .0000 .0001 .0002 .0000 .0000 .0005)], A => [qw( .9799 .0002 .0009 .0010 .0003 .0008 .0017 .0021 .0002 .0006 + .0004 .0002 .0006 .0002 .0022 .0035 .0032 .0000 .0002 .0018)], W => [qw( .0000 .0002 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 + .0000 .0000 .0000 .0001 .0000 .0001 .0000 .9995 .0001 .0000)], S => [qw( .0028 .0011 .0034 .0007 .0011 .0004 .0006 .0016 .0002 .0002 + .0001 .0007 .0004 .0003 .0017 .9800 .0038 .0005 .0002 .0002)], P => [qw( .0013 .0005 .0002 .0001 .0001 .0008 .0003 .0002 .0005 .0001 + .0002 .0002 .0001 .0001 .9935 .0012 .0004 .0000 .0000 .0002)], H => [qw( .0001 .0008 .0018 .0003 .0001 .0020 .0001 .0000 .9933 .0000 + .0001 .0001 .0000 .0002 .0003 .0001 .0001 .0001 .0004 .0001)], D => [qw( .0006 .0000 .0042 .9869 .0000 .0006 .0053 .0006 .0004 .0001 + .0000 .0003 .0000 .0000 .0001 .0005 .0003 .0000 .0000 .0001)], R => [qw( .0001 .9929 .0001 .0000 .0001 .0010 .0000 .0000 .0010 .0003 + .0001 .0019 .0004 .0001 .0004 .0006 .0001 .0008 .0000 .0001)], G => [qw( .0021 .0001 .0012 .0011 .0001 .0003 .0007 .9906 .0001 .0000 + .0001 .0002 .0001 .0001 .0003 .0021 .0003 .0000 .0000 .0005)]); #SVEQRISTDIGQAYQLQGLGSNLRSIRSKTGAGEVNYIDAAKSVNDNQLLAEIG $string='AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; @seq=split(//,$string); $size=scalar(@seq); print "$size\n"; foreach $seq (@seq) { &mutate($seq) ; print "##########SEQ=$seq\tRANDOM=$ran\tK=$k################"; usleep (1000000); } $k=0; $p=0; sub mutate # Start Of Sub { $ran=`awk 'BEGIN {{srand()} {print rand()}}'`; for ($j = 1; $j <= 20;$j++) { $mut[$j]=$nuc{$seq}[$j]; } for ($i=1; $i<=20; $i++) { print "$mut[$i]\t$ran\t"; if ($ran < $mut[$i]) {#print "\n$mut[$i] \t hello"; push (@names, $i); print "i=$i"; #push (@names, '-'); } last if $ran < $mut[$i]; print"\tran=$ran\t muti=$mut[$i]"; $k =$mut[$i]; print "K = $k"; } $p++; #counter for serial number } # End Of Sub # $nam=join ' ',@names; # for ($j = 0; $j <=$size;$j++) # {print $names[$j];} print"\n"; for ($j = 0; $j < $size;$j++) { if($names[$j]==1) {$names[$j]="A";} elsif($names[$j]==2) {$names[$j]="R";} elsif($names[$j]==3) {$names[$j]="N";} elsif($names[$j]==4) {$names[$j]="D";} elsif($names[$j]==5) {$names[$j]="C";} elsif($names[$j]==6) {$names[$j]="Q";} elsif($names[$j]==7) {$names[$j]="E";} elsif($names[$j]==8) {$names[$j]="G";} elsif($names[$j]==9) {$names[$j]="H";} elsif($names[$j]==10) {$names[$j]="I";} elsif($names[$j]==11) {$names[$j]="L";} elsif($names[$j]==12) {$names[$j]="K";} elsif($names[$j]==13) {$names[$j]="M";} elsif($names[$j]==14) {$names[$j]="F";} elsif($names[$j]==15) {$names[$j]="P";} elsif($names[$j]==16) {$names[$j]="S";} elsif($names[$j]==17) {$names[$j]="T";} elsif($names[$j]==18) {$names[$j]="W";} elsif($names[$j]==19) {$names[$j]="Y";} else {$names[$j]="V";} } print "orig = $string \nmuta = "; for ($j = 0; $j <=$size;$j++) {print $names[$j];} @arr = %nuc; print "@arr";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: string mutation script behaving erraticaly
by McA (Priest) on Jun 25, 2012 at 20:17 UTC | |
|
Re: string mutation script behaving erraticaly
by toolic (Bishop) on Jun 25, 2012 at 19:33 UTC | |
|
Re: string mutation script behaving erraticaly
by choroba (Cardinal) on Jun 25, 2012 at 20:45 UTC | |
by zing (Beadle) on Jun 25, 2012 at 22:15 UTC | |
by choroba (Cardinal) on Jun 25, 2012 at 23:40 UTC | |
by zing (Beadle) on Jun 26, 2012 at 12:17 UTC |