fixed a stupid bug in fastq reading

This commit is contained in:
Heng Li 2013-02-11 11:27:35 -05:00
parent 59eaf650ac
commit 987d4b4205
3 changed files with 7 additions and 7 deletions

6
bseq.c
View File

@ -41,15 +41,15 @@ bseq1_t *bseq_read(int chunk_size, int *n_, void *ks1_, void *ks2_)
size += seqs[n++].l_seq;
if (ks2) {
trim_readno(&ks2->name);
kseq2bseq1(ks2, &seqs[n++]);
kseq2bseq1(ks2, &seqs[n]);
size += seqs[n++].l_seq;
}
if (size >= chunk_size) break;
}
*n_ = n;
if (size < chunk_size) { // test if the 2nd file is finished
if (size == 0) { // test if the 2nd file is finished
if (ks2 && kseq_read(ks2) >= 0)
fprintf(stderr, "[W::%s] the 1st file has fewer sequences.\n", __func__);
}
*n_ = n;
return seqs;
}

View File

@ -644,21 +644,21 @@ int mem_process_seqs(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns
#ifdef HAVE_PTHREAD
if (opt->n_threads == 1) {
worker1(w);
mem_pestat(opt, bns->l_pac, n, regs, pes);
if (opt->is_pe) mem_pestat(opt, bns->l_pac, n, regs, pes);
worker2(w);
} else {
pthread_t *tid;
tid = (pthread_t*)calloc(opt->n_threads, sizeof(pthread_t));
for (i = 0; i < opt->n_threads; ++i) pthread_create(&tid[i], 0, worker1, &w[i]);
for (i = 0; i < opt->n_threads; ++i) pthread_join(tid[i], 0);
mem_pestat(opt, bns->l_pac, n, regs, pes);
if (opt->is_pe) mem_pestat(opt, bns->l_pac, n, regs, pes);
for (i = 0; i < opt->n_threads; ++i) pthread_create(&tid[i], 0, worker2, &w[i]);
for (i = 0; i < opt->n_threads; ++i) pthread_join(tid[i], 0);
free(tid);
}
#else
worker1(w);
mem_pestat(opt, bns->l_pac, n, regs, pes);
if (opt->is_pe) mem_pestat(opt, bns->l_pac, n, regs, pes);
worker2(w);
#endif
for (i = 0; i < n; ++i) {

View File

@ -58,7 +58,7 @@ int main_mem(int argc, char *argv[])
ks = kseq_init(fp);
if (optind + 2 < argc) {
fp2 = gzopen(argv[optind + 2], "r");
ks2 = kseq_init(fp);
ks2 = kseq_init(fp2);
opt->is_pe = 1;
}
while ((seqs = bseq_read(opt->n_threads * opt->chunk_size, &n, ks, ks2)) != 0) {