I am trying to do this
samtools view -f 0x2 -b XX.bam | samtools view -b -F 0x200 - | samtools view -b -F 0x400 - |genomeCoverageBed
as I am not sure of how to combine bitwise flag.
Unfortunately this 'lazy' way consumes 2 extra threads.
There's a python script here http://biostar.stackexchange.com/questions/13079/flag-in-sam-format
But I am not sure how to change it so that I might be able to filter in one samtools step? (or two?)