Advertisement
Guest User

Gzip

a guest
Dec 8th, 2014
989
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. from __future__ import print_function
  2. import gzip
  3. import io
  4. import subprocess
  5.  
  6.  
  7. def regular():
  8.     i = 0
  9.     with gzip.open("human_g1k_v37.fasta.gz") as f:
  10.         for line in f:
  11.             i += 1
  12.     print(i)
  13.  
  14.  
  15. def buffered_gzip():
  16.     i = 0
  17.     gz_file = gzip.open("human_g1k_v37.fasta.gz")
  18.     gz_file.read1 = gz_file.read
  19.     with io.TextIOWrapper(gz_file) as f:
  20.         for line in f:
  21.             i += 1
  22.     print(i)
  23.  
  24.  
  25. def zcat()
  26.     i = 0
  27.     p = subprocess.Popen(
  28.         ["gzcat", "human_g1k_v37.fasta.gz"],
  29.         stdout=subprocess.PIPE
  30.     )
  31.  
  32.     for line in p.stdout:
  33.         i += 1
  34.     print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement