sam提取unmapped seq
__author__ = 'wanguan2000'
#coding=utf-8
import os.path
import os
import sys
import re
filename = '/home/wanguan2000/pg/myNGS/result_NGS/cui3132/s31_1_s31_2.sam'
n = 0
m = 0
mn = 0
mydict ={}
with open(filename,'rU') as f:
??? for line in f:
??????? line = line.rstrip()
??????? if not line:
??????????? break
??????? if not line.startswith('@'):
?????????? spline = line.split('\t')
?????????? if 'chr21' == spline[2]:
?????????????? mn+=1
?????????????? print line
??????????????
'''
?????????? if not spline[2].startswith('chr'): # or spline[10] == '*':
????????????? # print line
?????????????? n +=1
?????????????? mydict[spline[2]] = mydict.get(spline[2],0)+1
?????????? elif '*' in spline[10]:
?????????????? m +=1
?????????? elif '0' == spline[4]:
'''
?????????????? #mydict[spline[2]] = mydict.get(spline[2],0)+1
??????? #else:
??????????? #print line
print n
print m
print mn
'''
for mykey in mydict:
??? print('%s\t%d' % (mykey,mydict[mykey]))
???
def readSam(filename,filehead='@HWI-ST499'):
??? n = 0
??? with open(filename,'rU') as f:
??????? while True:
??????????? line = f.readline
??????????? line = line.rstrip()
??????????? if not line:
??????????????? break
??????????? if line.startswith(filehead):
??????????????? print line
???????
'''