This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Is There A Tool To Combine Samtools / Sam File Bitwise Flags?

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?)

samtools

2 answers

Seems a bit silly to answer my own question but can anyone verify if what I can do is

samtools view -f 0x2 -b XX.bam | samtools view -b -F 1536|genomeCoverageBed

combined the last two commands bit flag here http://picard.sourceforge.net/explain-flags.html

Hi Kevin,

That looks right to me. 0x200 = 2^9 = 512, 0x400 = 2^10 = 1024, 512 + 1024 = 1536.

Log in to answer this question.