Skip to content

Instantly share code, notes, and snippets.

@brentp
Created April 10, 2015 18:10
Show Gist options
  • Save brentp/c9b24554cff4bab0a0bc to your computer and use it in GitHub Desktop.
Save brentp/c9b24554cff4bab0a0bc to your computer and use it in GitHub Desktop.
from bx.bbi import bigwig_file
from bx.bbi import bigbed_file
print bigwig_file
import time
from hashlib import md5
prefix = '/data/gemini/data/hg19_fitcons_fc-i6-0_V1-01'
print "before bw: 8.6 seconds"
print "before bw: 8529aaef661eb479c2bfe6e1ee4107db"
print "before bb: 10.4 seconds"
print "before bb: d2424d770247e721b43c2729cbe160a0"
for suffix in ('bb', 'bw'):
t = time.time()
if suffix == 'bw':
bw = bigwig_file.BigWigFile(open("%s.%s" % (prefix, suffix)))
else:
bw = bigbed_file.BigBedFile(open("%s.%s" % (prefix, suffix)))
for chrom in range(1, 20):
bw.query('chr%i' % chrom, 100000, 200000, 20)
bw.query('chr%i' % chrom, 100000, 200000, 2000)
bw.query('chr%i' % chrom, 1000000, 1200000, 20)
bw.query('chr%i' % chrom, 1000000, 1200000, 2000)
bw.query('chr%i' % chrom, 1000000, 2000000, 20)
bw.query('chr%i' % chrom, 1000000, 2000000, 2000)
for i in range(100):
bw.query('chr%i' % chrom, 1000001 + i, 1000002 + i, 1)
if chrom == 19:
vals = []
for i in range(100):
res = bw.query('chr%i' % chrom, 1000001 + i, 1000002 + i, 1)
assert len(res) == 1
res = res[0]
val = "|".join("%s -> %.3f" % (k,v) for k, v in res.items())
vals.append(val)
print suffix + ":", md5("|".join(vals)).hexdigest()
print suffix + ":", time.time() - t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment