This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Extract Alignment With Mismatches From Bowtie Mapping

Hey everybody,

I mapped small RNA (18-30 nt) reads using bowtie [outputFile=> acceptedhits.bam] and allowed two mismatches. Now i want to extract only those sequence reads which have either one or two mismatches. Could anyone suggest me how me to extract only those alignments (from bam file) which have mismatches.

I could re-map using no mismatch and subtract it, but i don't think that is a good way to do.

Any help will be appreciated. Thank you for your help in advance !

cheers Chirag

bowtie bam

I haven't used bowtie1 in a while, but I would suspect that samtools view -h acceptedhits.bam | grep -v "NM:i:0" | samtools view -bSo filtered.bam - might work.

if one wants to use the sam file and filter based on mismatches , what could be the best way to do?

Honestly, I'd write a short script in python using pysam. Then you have maximum flexibility, even if it's a bit slower.

0 answers

No answers yet.

Log in to answer this question.