def chimeric_reads(bamfile, virus_contig, duplicates):
igv_chimeric_file = os.path.splitext(args.bamfile)[0] + ".chimeric.igv.bam"
if os.path.exists(igv_chimeric_file):
return igv_chimeric_file
with pysam.Samfile(args.bamfile, "rb") as in_handle, \
pysam.Samfile(igv_chimeric_file, "wb", template=in_handle) as out_handle:
for read in in_handle:
try:
chrom = in_handle.getrname(read.tid)
except ValueError:
continue
if not is_chimeric_read(read, chrom, virus_contig):
continue
if read.qname in duplicates:
continue
out_handle.write(read)
return igv_chimeric_file
评论列表
文章目录