As I understand it, FLAG 0 means a read is mapped to the forward strand and FLAG 16 for reverse strand.
If I have single-end reads and I want to get all the uniquely mapped reads. Could I just do something like this:
samtools view bamfile.bam | awk '$2 == 0 || $2 == 16'
I have two additional questions that I'm a bit confused about:
Does FLAG 0 and 16 or any other FLAG values imply uniqueness of mapping?
Can I use samtools only with -F or -f to get alignment records with FLAG of either 0 or 16?
I realized that I couldn't get uniquely mapped reads from
samtools view bamfile.bam | awk '$2 == 0 || $2 == 16'.
, what the command does is to get primary alignments, which contain uniquely mapped and primary alignments from multi-mapping reads.