BEGIN {
    OFS="\t";
}

{
    if (substr($1,1,1)=="@" || substr($13,6)+0>1) # HI:i:>1
       next;
    nMult = substr($12,6)+0;
    split($1,f1,":");
    split(f1[2], c, "_");
    vars = f1[3];

    allReads[vars]++;
    allReads["all"]++;

    if (nMult==0) {
        Unmapped[vars]++;
        Unmapped["all"]++;
    } else if (nMult==1) {
        dd = c[2]-$4;
        if (c[1]!=$3 || dd>10 || dd<-10) {
            Diffends[vars]++;
            Diffends["all"]++;
        } else {
            True[vars]++;
            True["all"]++;
        };
    } else {
        Mu[vars]++;
        Mu["all"]++;
    };
}

END {
    for (v in allReads) {
        print v, allReads[v]+0, True[v]+0, Unmapped[v]+0,Diffends[v]+0, Mu[v]+0, 1-True[v]/allReads[v], Unmapped[v]/allReads[v], Diffends[v]/allReads[v], Mu[v]/allReads[v];
    };
}
