def pileup(bamfile_name):
samfile = pysam.Samfile(bamfile_name,"rb")
output_pileup = open("test.cov", "w")
sum_cov=0
for pos_pileup in samfile.pileup():
sum_cov+=pos_pileup.n
if not pos_pileup.pos % 1e3:
av_cov=int(sum_cov/1e3)
sum_cov=0
print(pos_pileup.tid,pos_pileup.pos,av_cov,file=output_pileup)
评论列表
文章目录