This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extraction Of Desired Alignments From Sam File

hello every one,

after running bowtie2 by using "bowtie2-align -f AT_ref -f GAC.fasta -S 1.sam" and got the details summery 616571 reads; of these:

616571 (100.00%) were unpaired; of these:

180433 (29.26%) aligned 0 times

306495 (49.71%) aligned exactly 1 time

129643 (21.03%) aligned >1 times,

as I guess, my chimeric reads would be in 129643 (21.03%) aligned >1 times out of 616571 reads; but I am not be able to extract these alignments from my output sam file. I don't know how to write syntax for this purpose. please suggest me.

thank you

sam bowtie2

The bowtie2 executable is actually a Perl wrapper script that calls the compiled bowtie2-align binary. It is recommended that you always run the bowtie2 wrapper and not run bowtie2-align directly.

1 answer

Here's one way to extract duplicate alignments from a SAM file.

Note that I'm assuming duplicate alignments == SAM records with the same QNAME

samtools view -F 0x4 input.sam | cut -f1 | sort | uniq -d | grep -F -f - input.sam

I haven't tested this, but you should do samtools view input.sam | cut -f1 | sort | uniq -d | wc -l first, to see if you get the same counts for duplicate reads as bowtie2's. If it's not the same, try playing around with the -f and/or -F flag to filter the reads first (I'm using -F 0x4 already to filter out unmapped reads).

Log in to answer this question.