#!/usr/local/bin/perl # goes through a file of alpha values (S per line, and H lines), # and returns a grid of `above-threshold' markers sub bynumber { $a <=> $b; } sub bycount { $count[$a] <=> $count[$b] ; } $symbol="X"; $dots="."; $f=1; $t=127; $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 ; if($th > 0.0 || $show > 0 ) { $spacer = $dots x ($w) ; } $white = " " x ($w) ; while (<>) { if ($_ ne "\n") { @fields = split(' ',$_); if( $show > 0 ) { @sorted = sort bynumber @fields[$f..$t] ; $th = $sorted[$H - $show - 1] ; } if ( $#fields < $t ) { print STDERR "warning, too few fields\n" ; } else { $h ++ ; $out[$h] = sprintf("%3d|",$h); $count[$h] = 0; for ( $N = 1 , $i = $f ; $i <= $t ; $i++ , $N ++ ) { if ( (($smallest==0)&&($fields[$i] > $th)) || (($smallest==1)&&($fields[$i] < $th)) ) { $out[$h] = $out[$h].$symbol ; $count[$h] ++ ; } else { $out[$h] = $out[$h].$spacer ; } if ( ! ($N%$linelength) ) { $out[$h] = $out[$h]."\n |" ; } } } } } @sortout = @out[sort bycount $[..$h] ; for ( $i = 1 ; $i <= $h ; $i ++ ) { print $sortout[$i] , "\n" ; if ( $newli ) { print "\n" ;} }