Reputation: 81
I'm trying to using pysam
to filter a .bam file for mapping quality and excluding flags.
I know I can use .fetch()
and iterate through reads that way, but I'm guessing it's faster to first use pysam.view()
However, when I try this on a large .bam, it appears to be trying to read in the entire file before returning any output. I want it to "yield" one read at a time. Is there a way to do this?
Here's my code:
for r in pysam.view('-q','255','-F','3840',input_bam):
print(r)
break
It's just hanging and never gets to the print statement because I believe it's trying to read in the whole .bam file before providing any output.
Upvotes: 1
Views: 177