for i, p in enumerate(pos):
for pileupcolumn in sf.pileup(ch, p-4, p+5, min_mapping_quality=minMapQual, min_base_quality=minBaseQual, truncate=True):
basePos = pileupcolumn.pos
for pileupread in pileupcolumn.pileups:
query_pos = pileupread.query_position
if not pileupread.is_del and not pileupread.is_refskip:
baseCall = pileupread.alignment.query_sequence[query_pos]
# the rest of the code is omitted here
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
However I found this is pretty slow (a lot slower than samtools's mpileup command line tool). I wonder if there could be a more efficient way to do what I want.Thanks!