This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to extract aligned exactly 1 time in Single end read?

I like to have exactly 1 match reads (6729690) from output of bowtie2 aligner. the blow cod is what I have used for aligning.

bowtie2 --very-sensitive --score-min C,0,0 -p 8 -x Genome_Index  input.fastq.gz -S output.sam

  8506903 reads; of these:
  8506903 (100.00%) were unpaired; of these:
 923759 (10.86%) aligned 0 times
 6729690 (79.11%) aligned exactly 1 time
853454 (10.03%) aligned >1 times
89.14% overall alignment rate

Also, I used :

samtools view -hf "AS:i:" output.sam | grep -v "XS:i:" > unique_output.sam
samtools view unique_output.sam | wc -l

but I got 7653449 reads that is (923759 + 6729690)

Is my code right?

How can I get only 6729690 reads?

alignment bowtie2 bwa

1 answer

You want to remove unaligned reads ?

samtools view -F 4

Good! Thanks !. it is working

The bitwise flag filtering is quiet powerful, check this page to get an idea what flag combination exist.

Log in to answer this question.