From 2d01a297fbccfcd81f306f202bec91dbafa89b03 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Sat, 9 Mar 2013 18:05:50 -0500 Subject: [PATCH] Improving 'properly paired' flag. If one end has a low quality tail that happens to have a score-20 hit, the pair won't be flagged as properly paired because bwa-mem thought it has multiple hits. By filtering with -T, we won't have this problem. --- bwa.1 | 2 +- bwamem_pair.c | 2 +- main.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bwa.1 b/bwa.1 index 495df69..3e92456 100644 --- a/bwa.1 +++ b/bwa.1 @@ -235,7 +235,7 @@ attached to every read in the output. An example is '@RG\\tID:foo\\tSM:bar'. .BI -T \ INT Don't output alignment with score lower than .IR INT . -This option only affects output. [30] +This option affects output and occasionally SAM flag 2. [30] .TP .B -a Output all found alignments for single-end or unpaired paired-end reads. These diff --git a/bwamem_pair.c b/bwamem_pair.c index bbbbe02..b9a68f1 100644 --- a/bwamem_pair.c +++ b/bwamem_pair.c @@ -260,7 +260,7 @@ int mem_sam_pe(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, co // check if an end has multiple hits even after mate-SW for (i = 0; i < 2; ++i) { for (j = 1; j < a[i].n; ++j) - if (a[i].a[j].secondary < 0) break; + if (a[i].a[j].secondary < 0 && a[i].a[j].score >= opt->T) break; is_multi[i] = j < a[i].n? 1 : 0; } if (is_multi[0] || is_multi[1]) goto no_pairing; // TODO: in rare cases, the true hit may be long but with low score diff --git a/main.c b/main.c index 505cfbd..a49bdf8 100644 --- a/main.c +++ b/main.c @@ -3,7 +3,7 @@ #include "utils.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.7.1-r347" +#define PACKAGE_VERSION "0.7.1-r348-beta" #endif int bwa_fa2pac(int argc, char *argv[]);