I have a single-ended sam files generated from bwa with default settings for NIPT calculation. How can I extract a sam or bam files that contains only alignments that have 0 mismatch by using samtools?
I have a single-ended sam files generated from bwa with default settings for NIPT calculation. How can I extract a sam or bam files that contains only alignments that have 0 mismatch by using samtools?
samtools view -e '[NM]==0' -O BAM -o out.bam in.bam
requires a recent version of samtools.
You could use this samtools view -h bwa.bam | grep "NM:i:0" | samtools view -O BAM -o bwa.filtered.bam
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Oops those were from my notes dates 5 years back my bad. edited my answer.