def getProperPair(self,outfile=None):
'''Extract proper paried mapped reads.'''
if outfile is None:
outfile = self.fileName + ".PP.sam"
FO=open(outfile,'w')
PPcount=0
print >>sys.stderr, "Writing proper paired reads to\"",outfile,"\"... ",
for line in self.f:
hits=[]
if line[0] == '@':continue #skip head lines
if ParseSAM._reExpr2.match(line):continue #skip blank lines
field=line.rstrip('\n').split()
flagCode=string.atoi(field[1])
if ((flagCode & 0x0001) != 0) and ((flagCode & 0x0002)!=0):
PPcount +=1
FO.write(line)
FO.close()
print >>sys.stderr, str(PPcount) + " reads were saved!\n",
self.f.seek(0)
评论列表
文章目录