Created
June 10, 2014 15:56
-
-
Save nickloman/f48cdff87e846b677d50 to your computer and use it in GitHub Desktop.
mapping_stats.py - for BLASR SAM output, requires Pysam
This file contains hidden or 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
import pysam | |
import sys | |
samfile = pysam.Samfile(sys.argv[1], "rb") | |
fields = ['Name', 'QueryLen', 'AlignLen', 'NumMismatches'] | |
print "\t".join(fields) | |
for read in samfile: | |
t = dict(read.tags) | |
results = [] | |
results.append(read.qname.ljust(25)) | |
results.append(t['XQ']) | |
results.append(t['XL']) | |
results.append(t['NM']) | |
print "\t".join([str(r) for r in results]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment