Last active
April 14, 2017 12:52
-
-
Save wdecoster/5f1c10401b1d567a2fd132deb90b80cd 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
import sys | |
import re | |
import pysam | |
def extractDisagreement(bam): | |
samfile = pysam.AlignmentFile(bam, "rb") | |
for read in samfile.fetch(): | |
NMdef = read.get_tag("NM")/read.query_alignment_length | |
MDdef = sum([len(item) for item in re.split('[0-9^]', read.get_tag("MD"))])/read.query_alignment_length | |
if NMdef - MDdef > 0.2: | |
print('\t'.join( | |
[ | |
str(read.get_tag("NM")), | |
str(sum([len(item) for item in re.split('[0-9^]', read.get_tag("MD"))])), | |
read.get_tag("MD"), | |
read.cigarstring, | |
]) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment