I just sat down to write my first Nim
script to parse a .vcf
(Variant Call Format) file. This file format stores genetic mutations from sequencing data.
For scripting languages, I 'grew up' on Perl
and later migrated to Python
, but I would love to use a language with the speed that Nim
offers. I realize Nim
is still young, but I couldn't even find a clear example for how to open and read a .gz
(gzip
) file (preferably line by line).
Can anyone provide a simple example to open and read a gzip
file using Nim
, line by line?
In Python
, I'm accustomed to the following (uber-simple) code:
import gzip
my_file = gzip.open('my_file.vcf.gz', 'w')
for line in my_file:
# do something
my_file.close()
I have seen related questions, but they're not clear. The posts are also relatively old and I hope/suspect something better has come about. Here's what I've found:
- Read gzip-compressed file line by line
- File, FileStream, and GZFileStream
- Reading files from tar.gz archive in Nim
Really appreciate it.
P.S. I also think it would be useful if someone created a Nim
tag in StackOverflow. I do not have the reputation to create tags.