Created
April 23, 2016 03:56
-
-
Save dnbaker/2e5cd2f0067ff92928a56d837087f0ad to your computer and use it in GitHub Desktop.
qchar counts
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
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