BEGIN{# call with samtools view -F 4 r374c.bam | awk -f /data/results/tools/ngs/sam/sam2aligned-fasta1.awk > r374.fa # $me = 10 ** (-$mQ / 10.0); # Given 1000, for example, read alignments with mapping quality being 30, one of them will be wrong in average. FS="\t"; print "MQ cutoff"th >"/dev/stderr"; }{ id=$1;ref=$3;cig=$6;s=$10;mq=$5; o[mq]++;n++; if(i[id]>0){print "ERR "id" not uniq." >"/dev/stderr";} i[id]++; if (mq>=th){print ">"id,ref,cig,mq;print s;p++;} }END{ print "Passed "p" mappings of "n" "100.0*p/n" %" >"/dev/stderr"; for (mq in o) {print mq" "100.0*o[mq]/n" "o[mq] >"/dev/stderr";} }