Skip to content

Commit

Permalink
Writing SAM files may leave htsExactFormat as text_format
Browse files Browse the repository at this point in the history
[NEWS]
* Fix legacy API's samopen() to write headers only with "wh" when writing
  SAM files.  Plain "w" suppresses headers for SAM file output, but this
  was broken in 1.2.
  • Loading branch information
jmarshall committed Mar 9, 2015
1 parent 918a567 commit 8a5a91a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sam.c
Expand Up @@ -58,9 +58,10 @@ samfile_t *samopen(const char *fn, const char *mode, const void *aux)
fprintf(stderr, "[samopen] no @SQ lines in the header.\n");
}
else {
enum htsExactFormat fmt = hts_get_format(fp->file)->format;
fp->header = (bam_hdr_t *)aux; // For writing, we won't free it
fp->is_write = 1;
if (hts_get_format(fp->file)->format != sam || strchr(mode, 'h')) sam_hdr_write(fp->file, fp->header);
if (!(fmt == text_format || fmt == sam) || strchr(mode, 'h')) sam_hdr_write(fp->file, fp->header);
}

return fp;
Expand Down

0 comments on commit 8a5a91a

Please sign in to comment.