Is there a way to filter bases in BAM files based on phred quallities through python's pysam ?I have a code here thatTakes the nucleobases per position from a BAM file using pysam's pileup functionSaves it in ReverseList and ForwardList based on both strands (i.e forward and reverse), I want to reject those bases that have phred quality below 25 to be not stored in the ForwardList and ReverseList lists so that they are not used for further analysis. samfile = pysam.Samfile( filename, rb ) ReverseList = [''] * lenref ForwardList = [''] * lenref for pileupcolumn in samfile.pileup() :     for pileupread in pileupcolumn.pileups:         if (pileupread.alignment.mapping_quality <= 15):               continue               if not pileupread.is_del and not pileupread.is_refskip:               if pileupread.alignment.is_reverse: #negative                      ReverseList[pileupcolumn.pos] += pileupread.alignment.query_sequence[pileupread.query_position]               else:                      ForwardList[pileupcolumn.pos] += pileupread.alignment.query_sequence[pileupread.query_position] samfile.close()Where lenref = 16569(length of mitochondrial genome) and filename is the name of BAM file. I want to filter based of phred qualities of bases.
Filtering bases based on phred qualities with pysam
bam;python;pysam