def get_bam_pairs(bams):
"""
Function returns pairs of bam files because sample ID relies
on samples being encoded with a '.'
@bams A List of Bam files.
"""
### TODO Use the read group to merge the reads, far smarter!
bam_list = {}
for bam in bams:
sam = pysam.AlignmentFile(bam,'rb')
sample_id = (sam.header['RG'][0]['SM'])
try:
bam_list[sample_id].append(bam)
except KeyError:
bam_list[sample_id] = [bam]
return bam_list
评论列表
文章目录