residue_entropy 1.2 KB

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