#! /usr/bin/gawk -f # Last edited on 2005-06-04 00:26:39 by stolfi BEGIN { # Converts ".est" file to numric format, suitable for # plotting. # Output fields: # INDEX BASE TRUEC PROBC TRUEPH ESTPH PHERR PHPROB } /^[>]/ { next; } // { # Remove "*" markers: gsub(/[*]/, " ", $0); # Get main fields x = $1; # Base index b = $2; # Base letter pi = $3; # Estimated Pr(I) pe = $4; # Estimated Pr(E) pf = $5; # Estimated Pr(F) pg = $6; # Estimated Pr(G) # Ignore lines with no prediction: if(pi+pe+pf+pg == 0) { next; } pre = substr($7,1,1); # Predicted label letter gab = substr($7,3,1); # Correct (?) label letter pc = pe+pf+pg; # Estimated {Pr(C)} gc = (gab == "I"?0:1); # Correct (?) {Pr(C)}, 0 or 1: # Get the numeric phase {s} (1,2,3) and its probability {ps}: s = 1; ps = pe; if(pf>ps){ps = pf; s = 2;} if(pg>ps){ps = pg; s = +3;} # Convert {ps} to conditional {Pr(s|C)}: ps = (ps+0.00000000001)/(pc+0.00000000001) # Get the correct (?) phase {gs}: gs = index("EFG",gab)+0; # Compute phase error {es}: if (gs == 0) { es = 0; } else { es = (s-gs+4)%3 - 1; } # Print output line printf "%10d %s", x, b; printf " %d %8.6f", gc, pc; printf " %d %d %+2d %8.6f", gs, s, es, ps; printf "\n"; }