Is there a way to fetch a read efficiently from a BAM file, using Pysam or a similar module (from Python), by its read ID?
For example, if I have a list of read IDs, "read_ids", I want to do something like:
bam_file = pysam.Samfile(bam_filename, "rb")
for read_id in read_ids:
# fetch the read id?
my_aligned_read = bam_file.fetch(read_id)
is there a way to do this? The indexed/sorted BAM format should have all this information I am just wondering how to retrieve it.
thanks.
I am hitting the same issue ..just wondering what solution worked out for you ??