Created
October 8, 2015 10:43
-
-
Save mattions/e942416429c395a60d84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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