def filter_sam_dups(filename,ids_to_discard):
"""
Reads a SAM file, returns a set() of duplicated reads
(reads which are listed more than once)
"""
try:
sam=file(filename,'r')
for linenum,line in enumerate(sam):
err = "input error in '%s' line %d: " % (filename, linenum+1)
line = line.strip()
if line[:1]=='@':
print line
continue
flds = line.split('\t')
read_id = flds[0]
if not (read_id in ids_to_discard):
print line
except IOError as e:
if e.errno == errno.EPIPE:
sys.exit(0) # exit silently
# TODO: this is a cop-out, hard to tell what's the exact error
# and give informative,useful error message to the user.
sys.exit("I/O error: %s" % (str(e)))
sam-discard-dups.py 文件源码
python
阅读 46
收藏 0
点赞 0
评论 0
评论列表
文章目录