#!/usr/local/bin/perl # goes through a file of alpha values (H per line, and N lines), # and returns a reversed grid of `above-threshold' markers, N per line, # and H lines, with space, so that this can easily be run down a picture # of aligned globins. sub bynumber { $a <=> $b; } sub bycount { $count[$a] <=> $count[$b] ; } $symbol="X"; $dots="."; $f=2; $t=21; $w=1; $th=35.0; $show=0; $left=0; $smallest=0; $linelength=50; $newli = 0 ; eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; $f--; $t--; if ($t<$f) { $t = $f ; } $H = $t - $f + 1 ; for ( $i = 1 ; $i <= $H ; $i ++ ) { $out[$i] = sprintf("%3d|",$i); $count[$i]=0; } if($th > 0.0 || $show > 0 ) { $spacer = $dots x ($w) ; } $white = " " x ($w) ; $N = 1 ; while (<>) { if ($_ ne "\n") { @fields = split(' ',$_); if( $show > 0 ) { @sorted = sort bynumber @fields[$f..$t] ; $th = $sorted[$H - $show - 1] ; } for ( $i = $f , $h = 1 ; $i <= $t ; $i++ , $h ++ ) { if ( (($smallest==0)&&($fields[$i] > $th)) || (($smallest==1)&&($fields[$i] < $th)) ) { $out[$h] = $out[$h].$symbol ; $count[$i] ++ ; } else { $out[$h] = $out[$h].$spacer ; } if ( ! ($N%$linelength) ) { $out[$h] = $out[$h]."\n\n |" ; } } $N++ ; } } @sortout = @out[sort bycount $[..$H] ; for ( $i = 1 ; $i <= $H ; $i ++ ) { print $sortout[$i] , "\n" ; if ( $newli ) { print "\n" ;} }