#!/bin/sh time gzip -d -c risearch_chr1:143971112-143971134:+:FAM72C.out.gz > risearch_chr1:143971112-143971134:+:FAM72C.out
0.28s user 0.02s system 99% cpu 0.297 total
然后测试python
import gzip defparse_gzip_py(ris_file): inf = gzip.open(ris_file, 'rt') withopen("test_py_gz.txt","w") as f: for line in inf: f.write(line+"\n")
inf.close()
%timeit parse_gzip_py("risearch_chr1:143971112-143971134:+:FAM72C.out.gz") 399 ms +/- 1.91 ms per loop
Julia 里面有两个解析Gzip的包,分别
是GZip.jl 和 CodecZlib.jl。
我们分别来测试一下
using GZip function parse_gzip_file(filename::String) out = open("test_gzipjl.txt","w") zips = GZip.open(filename) while!eof(zips) line = readline(zips) println(out, line) end close(out) end
function parse_gzi_trans(filename::String) out = open("test_trans.txt","w") stream = GzipDecompressorStream(open(filename)) for line in eachline(stream) println(out, line) end close(out) end