X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bam_mcns.c;h=40335ee37cac09735f6f7722ccb4e5e7caeea19f;hb=7f8bb285b631bd30a116ff5b5495563c7f5438f2;hp=7ef9f0f44702d9f6e4b499681f328ffe594b5afd;hpb=fb9ec864a4db78d58c5aba13c6c24ce4b610ab57;p=samtools.git diff --git a/bam_mcns.c b/bam_mcns.c index 7ef9f0f..40335ee 100644 --- a/bam_mcns.c +++ b/bam_mcns.c @@ -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 } }