def filter_bool(self, output_filename, mask):
"""Select and Write reads using a mask
:param str output_filename: name of output file
:param list list_bool: True to write read to output, False to ignore it
"""
assert output_filename != self.filename, \
"output filename should be different from the input filename"
assert len(mask) == self._N, \
"list of bool must be the same size as BAM file"
self.reset()
with pysam.AlignmentFile(output_filename, "wb", template=self.data) as fh:
for read, keep in zip(self.data, mask):
if keep:
fh.write(read)
评论列表
文章目录