def filter(self, bam, read): if read.is_unmapped: return False if read_calc_mismatches(read) <= self.num: return True chrom = bam.getrname(read.tid) mm = 0 snps = 0 for op, pos, seq in read_calc_variations(read): if not self.dbsnp.is_valid_variation(chrom, op, pos, seq, self.verbose): mm += 1 else: snps += 1 if mm > self.num: return False if snps: read.tags = read.tags + [('ZS', snps)] return True