Question: How To Interpret The Flag Field In The Sam Specification
1
gravatar for deepthithomaskannan
6.1 years ago by
Canada
deepthithomaskannan230 wrote:

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

bam • 19k views
ADD COMMENTlink modified 3.1 years ago by -_-680 • written 6.1 years ago by deepthithomaskannan230

Answer is fine but it is not working so sorry

ADD REPLYlink modified 3.9 years ago • written 3.9 years ago by iyer.laxman40

What answer isn't working? Istvan's link to the "Explain SAM Flags" still works, as does that site.

ADD REPLYlink written 3.9 years ago by Devon Ryan85k
15
gravatar for Istvan Albert
6.1 years ago by
Istvan Albert ♦♦ 77k
University Park, USA
Istvan Albert ♦♦ 77k wrote:

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

ADD COMMENTlink modified 4.1 years ago by seidel6.6k • written 6.1 years ago by Istvan Albert ♦♦ 77k

great tool the "Explain SAM Flags"!, I expended A LOT of time understanding the combinations

ADD REPLYlink modified 6.1 years ago • written 6.1 years ago by JC6.8k
4
gravatar for swbarnes2
4.9 years ago by
swbarnes24.1k
United States
swbarnes24.1k wrote:

I think some of the confusion happens because we call them binary flags, but they are displayed in decimal in the .sam file, but when they are explained in the SAM specification document, they are displayed in hexadecimal.

ADD COMMENTlink written 4.9 years ago by swbarnes24.1k
3
gravatar for Damian Kao
6.1 years ago by
Damian Kao15k
USA
Damian Kao15k wrote:

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.

ADD COMMENTlink written 6.1 years ago by Damian Kao15k

excellent summary - your blog was not listed in the planet feed - problem rectified!

ADD REPLYlink written 6.1 years ago by Istvan Albert ♦♦ 77k
3
gravatar for -_-
3.1 years ago by
-_-680
Canada
-_-680 wrote:

For even faster and more handy interpretation of the flag, try http://www.samformat.info/#/flag

ADD COMMENTlink written 3.1 years ago by -_-680

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

ADD REPLYlink written 3.1 years ago by Istvan Albert ♦♦ 77k

Agreed, added that feature, too and improved the binary illustration.

ADD REPLYlink written 3.1 years ago by -_-680

nice, I'll add this to my lecture notes ;-)

ADD REPLYlink written 3.1 years ago by Istvan Albert ♦♦ 77k
2
gravatar for JC
6.1 years ago by
JC6.8k
Mexico
JC6.8k wrote:

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

ADD COMMENTlink modified 6.1 years ago • written 6.1 years ago by JC6.8k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1674 users visited in the last hour