]> git.donarmstrong.com Git - samtools.git/blobdiff - bam_mcns.c
* samtools-0.1.8-7 (r639)
[samtools.git] / bam_mcns.c
index 7ef9f0f44702d9f6e4b499681f328ffe594b5afd..40335ee37cac09735f6f7722ccb4e5e7caeea19f 100644 (file)
@@ -115,9 +115,11 @@ static void set_allele(int ref, mc_aux_t *ma)
                for (j = i; j > 0 && sum[j] < sum[j-1]; --j)
                        tmp = sum[j], sum[j] = sum[j-1], sum[j-1] = tmp;
        ma->ref = sum[3]&3; ma->alt = sum[2]&3; ma->alt2 = -1;
-       if (ma->ref != ref) {
-               if (ma->alt == ref) tmp = ma->ref, ma->ref = ma->alt, ma->alt = tmp;
-               else ma->alt2 = ma->alt, ma->alt = ma->ref, ma->ref = ref;
+       if (ma->ref != ref) { // the best base is not ref
+               if (ref >= 0 && ref <= 3) { // ref is not N
+                       if (ma->alt == ref) tmp = ma->ref, ma->ref = ma->alt, ma->alt = tmp; // then switch alt and ref
+                       else ma->alt2 = ma->alt, ma->alt = ma->ref, ma->ref = ref; // then set ref as ref
+               } else ma->alt2 = ma->alt, ma->alt = ma->ref, ma->ref = sum[0]&3; // then set the weakest as ref
        }
 }