4.9 years ago by
University Park, USA
the flags are weird but may not be incorrect. There is a big "hole" in the spec there that says:
Bit 0x4 is the only reliable place to tell whether the read is unmapped. If 0x4 is set, no
assumptions can be made about RNAME, POS, CIGAR, MAPQ, bits 0x2, 0x10, 0x100 and
0x800, and the bit 0x20 of the previous read in the template.
So what that says is that if the read is unmapped the rest of the fields may still be set but we need to ignore that since the information may be incorrect. Now if one were to match the flags directly they would get a different result. I often seen tools completely ignore the above and assume that if the read is unmapped the rest of the fields will be changed accordingly. That is not the case.
To the OP: I think the correct course of action is to first remove all reads where both the read and the mate are unmapped. Then on the remaining reads the flags will work correctly. We have every right to complain we shouldn't need to do that - I mean c'mon having an unmapped read that is listed as mapping to say position xyz with a certain mapping quality - yes that actually can happen.