]> git.donarmstrong.com Git - samtools.git/blobdiff - sam.c
works
[samtools.git] / sam.c
diff --git a/sam.c b/sam.c
index f026bc80864dbc75557bf632c760978e54acc453..fa11df6c12b1abc589415d4d11fe269067ecd765 100644 (file)
--- a/sam.c
+++ b/sam.c
@@ -36,6 +36,13 @@ static void append_header_text(bam_header_t *header, char* text, int len)
        header->text[header->l_text] = 0;
 }
 
+int samthreads(samfile_t *fp, int n_threads, int n_sub_blks)
+{
+       if (!(fp->type&1) || (fp->type&2)) return -1;
+       bgzf_mt(fp->x.bam, n_threads, n_sub_blks);
+       return 0;
+}
+
 samfile_t *samopen(const char *fn, const char *mode, const void *aux)
 {
        samfile_t *fp;
@@ -79,7 +86,7 @@ samfile_t *samopen(const char *fn, const char *mode, const void *aux)
                } else { // text
                        // open file
                        fp->x.tamw = strcmp(fn, "-")? fopen(fn, "w") : stdout;
-                       if (fp->x.tamr == 0) goto open_err_ret;
+                       if (fp->x.tamw == 0) goto open_err_ret;
                        if (strchr(mode, 'X')) fp->type |= BAM_OFSTR<<2;
                        else if (strchr(mode, 'x')) fp->type |= BAM_OFHEX<<2;
                        else fp->type |= BAM_OFDEC<<2;