samtools view -q 255 WG.bam
will give you the uniquely mapped reads. At least it worked for me just a few minutes ago.
It is a little bit complicated to explain why Bowtie2 uses 255 in the mapping quality score to indicate uniquely mapped reads, but here is a very good blog that discusses the MAPQ score in bowtie2: http://biofinysics.blogspot.com/2014/05/how-does-bowtie2-assign-mapq-scores.html
My simple (but may not be correct) reasoning is,
- MAPQ=-10logP, P=the probability of the mapping is wrong
- 255 is to be used for mapped reads where the MAPQ is not available (SAM specification)
For a perfectly uniquely mapped read, the probability of getting wrong is 0, and we know log0 doesn't exit, so 255 is used here to indicate the perfect match.
Given this reasoning, if the reads could map to two positions, then the probability of the alignment is wrong is 0.5, so MAPQ = -10*log(0.5, base=10) ~ 3.
However, I might miss some "good" mapping by filtering on -q 255, as explained by the blog post I referred to previously. Please check that blog carefully.
according to the documentation of samtools -q is for skipping alignments with MAPQ smaller than INT which in your case 1
Thank you, but the results for the following command is 54792 lines too.
what command line have you used?