Entering edit mode
6.3 years ago
AHW
▴
90
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.
When you use the first grep command on
old.sam
, you are losing the header information innewfiltered.sam
, that's whysamtools view
command results in the error mentioned above.See: http://seqanswers.com/forums/showthread.php?t=12849 and http://seqanswers.com/forums/showthread.php?t=58221 for further details about extracting reads.
Thank you for your comment. I tried using
BBMap
and I used the commandreformat.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.