Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
brentp committed Aug 30, 2019
1 parent 987dfcd commit 98d31d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v0.2.21 (dev)
=======
+ hts/vcf allow setting id.
+ hts/vcf flush stdout on close.

v0.2.20
=======
+ hts/files (iterate over bgzipped or text files identically)
Expand Down
5 changes: 5 additions & 0 deletions src/hts/vcf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ proc newVariant*(): Variant =
new(result, destroy_variant)
result.c = bcf_init()

proc c_fflush(f: File): cint {.
importc: "fflush", header: "<stdio.h>", discardable.}

proc destroy_vcf(v:VCF) =
bcf_hdr_destroy(v.header.hdr)
if v.tidx != nil:
Expand All @@ -434,6 +437,8 @@ proc close*(v:VCF) =
when defined(debug):
stderr.write_line "[hts-nim] error closing vcf"
v.hts = nil
if v.fname in ["/dev/stdout", "-"]:
c_fflush(stdout)


proc copy_header*(v: var VCF, hdr: Header) =
Expand Down

2 comments on commit 98d31d7

@xbello
Copy link
Contributor

@xbello xbello commented on 98d31d7 Sep 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that c_fflush is already in https://github.com/nim-lang/Nim/blob/master/lib/system/sysio.nim, and it's interfaced with:

proc flushFile*(f: File) = discard c_fflush(f)

@brentp
Copy link
Owner Author

@brentp brentp commented on 98d31d7 Sep 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed. I've updated it to use that instead.

Please sign in to comment.