Skip to content

Instantly share code, notes, and snippets.

@mattions
Created October 8, 2015 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattions/e942416429c395a60d84 to your computer and use it in GitHub Desktop.
Save mattions/e942416429c395a60d84 to your computer and use it in GitHub Desktop.
from pysam import VariantFile
import time
def count_oldvar_reg(vcffile_reg, labels=["OLDVARS", "OLDVARS_A", "OLDVARS_B"]):
t_start = time.time()
bcf_in = VariantFile(vcffile_reg)
total = 0
reg = 0
for rec in bcf_in:
total += 1
for label in labels:
if label in rec.info:
reg += 1
break
print "Total: {0}".format(total)
print "Found: {0}".format(reg)
t_stop = time.time()
print "Time takes: {0} s.".format(t_stop - t_start)
from vcf import Reader
def count_oldvar(vcffile_reg):
t_start = time.time()
reader = Reader(filename=vcffile_reg)
total = 0
reg = 0
for variant in reader:
total += 1
for label in ["OLDVARS", "OLDVARS_A", "OLDVARS_B"]:
if label in variant.INFO:
reg += 1
break
print "Total: {0}".format(total)
print "Reg: {0}".format(reg)
t_stop = time.time()
print "Time takes: {0} s.".format(t_stop - t_start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment