Skip to content

Commit

Permalink
- set the buffer on stdin
Browse files Browse the repository at this point in the history
- fflush stdout in bwtaln after writing the header and set of
alignments.
  • Loading branch information
nh13 committed Aug 22, 2024
1 parent 70bc8ca commit 8d9f50c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions bwtaln.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ void bwa_aln_core(const char *prefix, const char *fn_fa, const gap_opt_t *opt)
strcpy(str, prefix); strcat(str, ".sa"); bwt_restore_sa(str, bwt);
free(str);
bwa_print_sam_hdr(bns, opt->rg_line);
fflush(stdout);
}

// core loop
Expand Down Expand Up @@ -252,6 +253,7 @@ void bwa_aln_core(const char *prefix, const char *fn_fa, const gap_opt_t *opt)
fprintf(stderr, "[bwa_aln_core] print alignments... ");
for (i = 0; i < n_seqs; ++i)
bwa_print_sam1(bns, seqs + i, 0, opt->mode, opt->max_top2);
fflush(stdout);
fprintf(stderr, "%.2f sec\n", (float)(clock() - t) / CLOCKS_PER_SEC);
}
else {
Expand Down
3 changes: 1 addition & 2 deletions utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ gzFile err_xzopen_core2(const char *func, const char *fn, const char *mode, int
fp = gzdopen(fileno((strstr(mode, "r"))? stdin : stdout), mode);
/* According to zlib.h, this is the only reason gzdopen can fail */
if (!fp) err_fatal(func, "Out of memory");
return fp;
}
if ((fp = gzopen(fn, mode)) == 0) {
else if ((fp = gzopen(fn, mode)) == 0) {
err_fatal(func, "fail to open file '%s' : %s", fn, errno ? strerror(errno) : "Out of memory");
}
if (0 < bufsize && gzbuffer(fp, bufsize) != 0) {
Expand Down

0 comments on commit 8d9f50c

Please sign in to comment.