Merge commit 'upstream/0.1.17'
[samtools.git] / bcftools / bcf2qcall.c
index 8634c9e36e86fef665676afee9df11a46cc2cd80..a86bac26354a7b6da298b46477579c3d59d4d246 100644 (file)
@@ -77,8 +77,8 @@ int bcf_2qcall(bcf_hdr_t *h, bcf1_t *b)
                for (k = j = 0; k < 4; ++k) {
                        for (l = k; l < 4; ++l) {
                                int t, x = map[k], y = map[l];
-                               if (x > y) t = x, x = y, y = t;
-                               g[j++] = p[x * b->n_alleles - x * (x-1) / 2 + (y - x)];
+                               if (x > y) t = x, x = y, y = t; // swap
+                               g[j++] = p[y * (y+1) / 2 + x];
                        }
                }
                printf("%s\t%d\t%c", h->ns[b->tid], b->pos+1, *b->ref);