Count exact match reads in SAM file
0
0
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.

alignment sam exactmatch • 2.6k views
ADD COMMENT
2
Entering edit mode

When you use the first grep command on old.sam, you are losing the header information in newfiltered.sam, that's why samtools 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.

ADD REPLY
0
Entering edit mode

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.

ADD REPLY

Login before adding your answer.

Traffic: 2152 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6