This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Count exact match reads in SAM file

I got the alignment result in SAM format using bowtie2. As bowtie2 does not have the setting for exact match, so I want to count the number of exact match.

I tried to use grep to extract the exact reads using grep AS:i:0 old.sam >> newfiltered.sam and when I try to count by samtools using samtools view -c newfiltered.sam, I get the following error

[E::sam_parse1] missing SAM header
[W::sam_read1] parse error at line 1
[main_samview] truncated file.

I would like to know how can I count the exact matches in the file.

alignment sam exactmatch

Thank you for your comment. I tried using BBMap and I used the command reformat.sh in=output.sam out=exact.fastq, however, I am not able to find how to extract exact matching reads. The given command extracts all the reads to the new file.

0 answers

No answers yet.

Log in to answer this question.