I have a bam file and a bed file that defines a list of SNPs. I would like to filter the bam file to contain only those reads with a minimum mapping quality that overlap at least one SNP with a minimum base quality.
Samtools seems to almost solve this problem, but not quite:
samtools depth -b snp_list -q 20 -Q 30 example.bam
allows me to count the number of alignments meeting my desired criteria, but not to produce a bam with these alignments.
samtools view -L snp_bed -q 30 example.bam
allows me to filter the alignments overlapping any SNP with minimum mapping quality, but not with a minimum base quality at the SNP sites. There is no -Q
option for samtools view, and the -q
option is for mapping quality
Can this be achieved in samtools? Or is there another preexisting tool that can?