Merge pull request #19 from jmarshall/check-qnames

Check that input files are name-sorted and the names of paired reads match
This commit is contained in:
Heng Li 2013-06-14 06:27:41 -07:00
commit 426e54740c
4 changed files with 9 additions and 5 deletions

View File

@ -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;
}

View File

@ -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();

View File

@ -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] <idxbase> <in1.fq> [in2.fq]\n\n");
fprintf(stderr, "Algorithm options:\n\n");

9
main.c
View File

@ -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;
}