#! /bin/csh -f # Last edited on 2025-05-01 18:46:28 by stolfi # Reads a list of "dex" features with counts (as from uniq -c). # Sorts them by number of connected X/e components. /bin/cat \ | gawk \ ' /./ { \ c=$2; gsub(/[Xe][Xe]*/,"@",c);gsub(/[^@]/,"",c);c=length(c); \ r=(match($2,/[D]/)>0); \ s=(match($2,/[X]/)>0); \ t=(match($2,/[e]/)>0); \ printf "%02d %d %d %d %s\n",c,r,s,t,$0; \ } \ ' \ | sort -b -k1 -k2 -k3 -k4 -k5nr \ | gawk \ ' /./ { \ if(($1!=c)||($2!=r)||($3!=s)||($4!=t)) \ { if(n>0) { printf "#%7d TOTAL c=%s r=%s s=%s t=%s\n", n,c,r,s,t; } \ c=$1; r=$2; s=$3; t=$4; n=0; \ } \ print substr($0,9); \ n+=$5; \ } \ END { \ if(n>0) { printf "#%7d TOTAL c=%s r=%s s=%s t=%s\n", n,c,r,s,t; } \ } \ '