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?
You could use this samtools view -h bwa.bam | grep "NM:i:0" | samtools view -O BAM -o bwa.filtered.bam
samtools view -h bwa.bam | grep "NM:i:0" | samtools view -O BAM -o bwa.filtered.bam
Thanks, can I replace bwa.bam with bwa.sam? Or I need to convert it to bam first?
this is wrong, the last command is trying to read a file bwa.filtered.bam. You want .. | samtools view -O BAM -o bwa.filtered.bam
.. | samtools view -O BAM -o bwa.filtered.bam
Hi, by somehow it shows error: no header when type together but worked when I type them separately
samtools view -e '[NM]==0' -O BAM -o out.bam in.bam
requires a recent version of samtools.
Oops those were from my notes dates 5 years back my bad. edited my answer.
Login before adding your answer.
Use of this site constitutes acceptance of our User Agreement and Privacy