great tool the "Explain SAM Flags"!, I expended A LOT of time understanding the combinations
Hi all ,
I created a sam file and converted it to bam file using samtools.
One of the record in bam file is :
HWI-ST1162:72:D0PMMACXX:5:1104:10496:88597 16 gi|355477192|ref|NC_007299.5| 1 255 101M * 0 0 TACCCCACTCACACTTATGGATAGATCAACTAAACAGAAAATTAACAAGGAAAAAAAAAACAAAAAAAACATGTATCTATAAAGCTCACTAAAGGAAAGCA 05DDDDCDDCDDDDDDDDDDDCDCCADDDCDDDEDDEDEEEEDDDDDDDDDDHJJJJJJIJJJJJJJJIIJJJJJIJGJJJJJJIIHGHHHHHFFFFFCCC XA:i:1 MD:Z:60A33C6 RG:Z:D0PMMACXX:IT27.48-3 NM:i:2
What does the second field means? What may be the possible values for second field of a bam file. In one paper I read it as a flag. But I could not find the explanation for value 0 and 16 .
Thanks, Deeps
5 answers
In a nutshell any integer number may be entered although some of these number may have contradictory or overlapping effects.
The best way to visualize the flag fields is via Explain SAM Flags web interface.
To also answer your question each flag corresponds to a bit set in a binary representation of the number
1 -> 00001
2 -> 00010
4 -> 00100
8 -> 01000
Then if you need to set flags 1 and 4 then the bits that will be set are 00101 and the integer flag would be 5
For even faster and more handy interpretation of the flag, try http://www.samformat.info/#/flag
this is neat but IMO it should work both ways, selecting rows should produce numbers.
building a number out of the desired flags is just as often needed
I wrote a blog post about this a while back: http://blog.nextgenetics.net/?e=18
It might be more detail than you need to know about how bitwise flags work.
excellent summary - your blog was not listed in the planet feed - problem rectified!
In short: 0 is a single-end read mapped in the forward strand, 16 is in the reverse strand. Check all the details about the bitwise flag in the samtools manual: http://samtools.sourceforge.net/samtools.shtml and SAM format description: http://samtools.sourceforge.net/SAM1.pdf
Log in to answer this question.
Answer is fine but it is not working so sorry
What answer isn't working? Istvan's link to the "Explain SAM Flags" still works, as does that site.