I'm trying to use bamnostic to basically read in a BAM, filter out reads where any of the bases have a quality < 10, and then write out the remaining lines to a new BAM file. However, I'm a bit confused as to how you write things out using bamnostic. Here's what I have so far:
import bamnostic as bs
input_bam = bs.AlignmentFile("inputbam.bam", 'rb')
output_bam = bs.AlignmentFile("outputbam.bam", 'wb')
for read in bam:
qual = read.query_qualities
if all(q >= 10 for q in qual):
output_bam.write(read)
But this fails. What's the correct way to write out the lines to a new bam file?
I even tried with the to_bam() method, but it fails as well due to TypeError: to_bam() takes exactly 1 argument (2 given):
out = bs.bam.BamWriter("filteredBam.bam", 'wb')
for read in bam:
qual = read.query_qualities
if all(q >= 10 for q in qual):
read.to_bam(out)
I'm trying to use bamnostic to basically read in a BAM, filter out reads where any of the bases have a quality < 10, and then write out the remaining lines to a new BAM file. However, I'm a bit confused as to how you write things out using bamnostic. Here's what I have so far:
But this fails. What's the correct way to write out the lines to a new bam file?
I even tried with the
to_bam()method, but it fails as well due toTypeError: to_bam() takes exactly 1 argument (2 given):