[16] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | @quant=( |
---|
| 4 | 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, |
---|
| 5 | 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, |
---|
| 6 | 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, |
---|
| 7 | 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, |
---|
| 8 | 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 |
---|
| 9 | ); |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | use POSIX; |
---|
| 13 | my($groupn)=@ARGV; |
---|
| 14 | my%hash; |
---|
| 15 | my$count=0; |
---|
| 16 | my$lines=0; |
---|
| 17 | |
---|
| 18 | if(!defined($groupn)){ |
---|
| 19 | print "Usage: residue_entropy <groupsize> \n"; |
---|
| 20 | exit(1); |
---|
| 21 | } |
---|
| 22 | $|=1; |
---|
| 23 | |
---|
| 24 | while (<STDIN>) { |
---|
| 25 | chop; |
---|
| 26 | my@nums = (); |
---|
| 27 | @nums = split(/,/); |
---|
| 28 | $lines++; |
---|
| 29 | |
---|
| 30 | my$step=$#nums/$groupn; |
---|
| 31 | for(my$i=0;$i<$step;$i++){ |
---|
| 32 | my$key=""; |
---|
| 33 | for(my$j=$i;$j<$#nums;$j+=$step){ |
---|
| 34 | if($nums[$j]<0){ |
---|
| 35 | $num=-$quant[int(-$nums[$j]*2)]; |
---|
| 36 | }else{ |
---|
| 37 | $num=$quant[int($nums[$j]*2)]; |
---|
| 38 | } |
---|
| 39 | $key.=":$num"; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | if(!defined($hash{$key})){ |
---|
| 43 | $count++; |
---|
| 44 | $hash{$key}=1; |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | if(($lines % 1000)==0){ |
---|
| 49 | print "\rworking... $lines lines, found $count values so far"; |
---|
| 50 | } |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | foreach $key (keys %hash){ |
---|
| 54 | print "\t$key\n"; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | print "\r$count values total \n"; |
---|
| 58 | print "Done.\n\n"; |
---|