r337: mem - always read even number of reads

In the old code, we may read odd number of reads from an interleaved fastq.
This commit is contained in:
Heng Li 2013-03-07 11:00:15 -05:00
parent 72817b664e
commit 3e3236dfc4
3 changed files with 7 additions and 2 deletions

2
bwa.c
View File

@ -55,7 +55,7 @@ bseq1_t *bseq_read(int chunk_size, int *n_, void *ks1_, void *ks2_)
kseq2bseq1(ks2, &seqs[n]);
size += seqs[n++].l_seq;
}
if (size >= chunk_size) break;
if (size >= chunk_size && (n&1) == 0) break;
}
if (size == 0) { // test if the 2nd file is finished
if (ks2 && kseq_read(ks2) >= 0)

View File

@ -106,6 +106,11 @@ int main_mem(int argc, char *argv[])
}
while ((seqs = bseq_read(opt->chunk_size * opt->n_threads, &n, ks, ks2)) != 0) {
int64_t size = 0;
if ((opt->flag & MEM_F_PE) && (n&1) == 1) {
if (bwa_verbose >= 2)
fprintf(stderr, "[W::%s] odd number of reads in the PE mode; last read dropped\n", __func__);
n = n>>1<<1;
}
if (!copy_comment)
for (i = 0; i < n; ++i) {
free(seqs[i].comment); seqs[i].comment = 0;

2
main.c
View File

@ -3,7 +3,7 @@
#include "utils.h"
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION "0.7.0-r336-beta"
#define PACKAGE_VERSION "0.7.0-r337-beta"
#endif
int bwa_fa2pac(int argc, char *argv[]);