From 3e3236dfc400b1157726af61468914f5ebcbdc8a Mon Sep 17 00:00:00 2001 From: Heng Li Date: Thu, 7 Mar 2013 11:00:15 -0500 Subject: [PATCH] r337: mem - always read even number of reads In the old code, we may read odd number of reads from an interleaved fastq. --- bwa.c | 2 +- fastmap.c | 5 +++++ main.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bwa.c b/bwa.c index 76b54ae..991b23a 100644 --- a/bwa.c +++ b/bwa.c @@ -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) diff --git a/fastmap.c b/fastmap.c index e6c2b1e..9204399 100644 --- a/fastmap.c +++ b/fastmap.c @@ -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; diff --git a/main.c b/main.c index d9a87f1..f7b3a03 100644 --- a/main.c +++ b/main.c @@ -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[]);