From 20dc9dd41add925d7770b27f9f0588afec5f519c Mon Sep 17 00:00:00 2001 From: John Marshall Date: Fri, 14 Jun 2013 13:57:22 +0100 Subject: [PATCH 1/3] Check that paired reads have the same QNAME This detects desynchronised input files, which occasionally happens due to user error or system failure. Checking the names just after printing them has no real performance implications because the strings are already in cache. (It might be better to check while reading the input, but that would be more complicated in the two-input-files case.) --- bwamem_pair.c | 2 ++ bwape.c | 1 + 2 files changed, 3 insertions(+) diff --git a/bwamem_pair.c b/bwamem_pair.c index 06aacff..c218925 100644 --- a/bwamem_pair.c +++ b/bwamem_pair.c @@ -301,6 +301,7 @@ int mem_sam_pe(const mem_opt_t *opt, const bntseq_t *bns, const uint8_t *pac, co h[1] = mem_reg2aln(opt, bns, pac, s[1].l_seq, s[1].seq, &a[1].a[z[1]]); h[1].mapq = q_se[1]; h[1].flag |= 0x80 | extra_flag; mem_aln2sam(bns, &str, &s[0], 1, &h[0], 0, &h[1]); s[0].sam = strdup(str.s); str.l = 0; mem_aln2sam(bns, &str, &s[1], 1, &h[1], 0, &h[0]); s[1].sam = str.s; + if (strcmp(s[0].name, s[1].name) != 0) err_fatal(__func__, "paired reads have different names: \"%s\", \"%s\"\n", s[0].name, s[1].name); free(h[0].cigar); free(h[1].cigar); } else goto no_pairing; return n; @@ -319,6 +320,7 @@ no_pairing: } mem_reg2sam_se(opt, bns, pac, &s[0], &a[0], 0x41|extra_flag, &h[1]); mem_reg2sam_se(opt, bns, pac, &s[1], &a[1], 0x81|extra_flag, &h[0]); + if (strcmp(s[0].name, s[1].name) != 0) err_fatal(__func__, "paired reads have different names: \"%s\", \"%s\"\n", s[0].name, s[1].name); free(h[0].cigar); free(h[1].cigar); return n; } diff --git a/bwape.c b/bwape.c index 08490e7..2c96e06 100644 --- a/bwape.c +++ b/bwape.c @@ -706,6 +706,7 @@ void bwa_sai2sam_pe_core(const char *prefix, char *const fn_sa[2], char *const f } bwa_print_sam1(bns, p[0], p[1], opt.mode, opt.max_top2); bwa_print_sam1(bns, p[1], p[0], opt.mode, opt.max_top2); + if (strcmp(p[0]->name, p[1]->name) != 0) err_fatal(__func__, "paired reads have different names: \"%s\", \"%s\"\n", p[0]->name, p[1]->name); } fprintf(stderr, "%.2f sec\n", (float)(clock() - t) / CLOCKS_PER_SEC); t = clock(); From 128ffc089b02f50fb9845d7dbadcf9accaa61a94 Mon Sep 17 00:00:00 2001 From: John Marshall Date: Fri, 14 Jun 2013 14:00:24 +0100 Subject: [PATCH 2/3] Complain when bwa mem is given too many filenames Reads in extra .fq filenames beyond "bwa mem index one.fq two.fq" will not be aligned, so complain about such invalid usage instead. --- fastmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastmap.c b/fastmap.c index b00ec00..40ccdf9 100644 --- a/fastmap.c +++ b/fastmap.c @@ -54,7 +54,7 @@ int main_mem(int argc, char *argv[]) else return 1; } if (opt->n_threads < 1) opt->n_threads = 1; - if (optind + 1 >= argc) { + if (optind + 1 >= argc || optind + 3 < argc) { fprintf(stderr, "\n"); fprintf(stderr, "Usage: bwa mem [options] [in2.fq]\n\n"); fprintf(stderr, "Algorithm options:\n\n"); From b88718d8f467121ad3a454758e99d05d5e7bc94a Mon Sep 17 00:00:00 2001 From: John Marshall Date: Fri, 14 Jun 2013 14:03:08 +0100 Subject: [PATCH 3/3] Reformat note for 80 columns, and fix typo --- main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 662d54f..0a5d8a8 100644 --- a/main.c +++ b/main.c @@ -46,10 +46,11 @@ static int usage() fprintf(stderr, " bwtupdate update .bwt to the new format\n"); fprintf(stderr, " bwt2sa generate SA from BWT and Occ\n"); fprintf(stderr, "\n"); - fprintf(stderr, "Note: To use BWA, you need to first index the genome with `bwa index'. There are\n"); - fprintf(stderr, " three alignment algorithms in BWA: `mem', `bwasw' and `aln/samse/sampe'. If\n"); - fprintf(stderr, " you are not sure which to use, try `bwa mem' first. Please `man ./bwa.1' for\n"); - fprintf(stderr, " for the manual.\n\n"); + fprintf(stderr, +"Note: To use BWA, you need to first index the genome with `bwa index'.\n" +" There are three alignment algorithms in BWA: `mem', `bwasw', and\n" +" `aln/samse/sampe'. If you are not sure which to use, try `bwa mem'\n" +" first. Please `man ./bwa.1' for the manual.\n\n"); return 1; }