]> git.donarmstrong.com Git - samtools.git/blobdiff - sam.c
* samtools-0.1.4-7 (r337)
[samtools.git] / sam.c
diff --git a/sam.c b/sam.c
index 9a6e201d75e24d366903ff4e937f80d71e45303c..04be5c57745a8036dce8b2e3ede563f38aa8cdbb 100644 (file)
--- a/sam.c
+++ b/sam.c
@@ -49,8 +49,10 @@ samfile_t *samopen(const char *fn, const char *mode, const void *aux)
        } else if (mode[0] == 'w') { // write
                fp->header = bam_header_dup((const bam_header_t*)aux);
                if (mode[1] == 'b') { // binary
+                       char bmode[3];
+                       bmode[0] = 'w'; bmode[1] = strstr(mode, "u")? 'u' : 0; bmode[2] = 0;
                        fp->type |= TYPE_BAM;
-                       fp->x.bam = strcmp(fn, "-")? bam_open(fn, "w") : bam_dopen(fileno(stdout), "w");
+                       fp->x.bam = strcmp(fn, "-")? bam_open(fn, bmode) : bam_dopen(fileno(stdout), bmode);
                        if (fp->x.bam == 0) goto open_err_ret;
                        bam_header_write(fp->x.bam, fp->header);
                } else { // text