Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.