From 8d9f50c255ac5ddd12b2a3101a7dd955f463565d Mon Sep 17 00:00:00 2001 From: Nils Homer Date: Mon, 13 Jun 2016 14:09:02 -0400 Subject: [PATCH] - set the buffer on stdin - fflush stdout in bwtaln after writing the header and set of alignments. --- bwtaln.c | 2 ++ utils.c | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bwtaln.c b/bwtaln.c index fbfcd2b..08a1ffd 100644 --- a/bwtaln.c +++ b/bwtaln.c @@ -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 @@ -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 { diff --git a/utils.c b/utils.c index c3f4e7a..b629f02 100644 --- a/utils.c +++ b/utils.c @@ -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) {