Skip to content

Instantly share code, notes, and snippets.

@dnbaker
Created April 23, 2016 03:56
Show Gist options
  • Save dnbaker/2e5cd2f0067ff92928a56d837087f0ad to your computer and use it in GitHub Desktop.
Save dnbaker/2e5cd2f0067ff92928a56d837087f0ad to your computer and use it in GitHub Desktop.
qchar counts
try:
from cytoolz import frequencies
except ImportError:
from collections import Counter as frequencies
# Works, but it's less than 3x as fast
# A simple pure python counter is twice as fast as Counter anyhow....
from itertools import chain
def get_qchars_counts(bampath):
'''
Quickly gets you a distribution of quality scores.
'''
return frequencies(chain.from_iterable(c.qual for
c in pysam.AlignmentFile(bampath)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment