Hi, I've been using Pysam to help me parse bam files. I noticed that in some cases, the Samtools Flag will be set to 0, and the SA tag will also be set. When I use the samtools read.is_supplemental, this will return False. I find this confusing because I would assume that if the SA tag is set, the segment would also be flagged as supplemental.
Under what circumstances will the SA tag be set but the FLAG tag indicating a supplemental alignment won't? Is this because according to the SAM file specifications, "it is required that one and only one line associated with the read satisfies ‘FLAG & 0x900 == 0’" so this flag is only set to 0 to meet those requirements even though it actually is a supplementary alignment?
What is the most reliable way to check for a supplemental alignment? Should I be using the Sam file FLAG or the SA tag?
The other thing I'm confused about is that for one particular read there may be multiple entries in the BAM file that are both supplementary and primary. My understanding is that you can only have one primary alignment. Given that this is a read that doesn't map linearly, is there an entry in the bam file for each place the read maps that can be combined to create the primary alignment? But then, I'm confused about how to interpret the SA flag for each of these entries, which also suggests that each of those segments may also map to additional places.
Thanks.
What software is making your bams?
They were created with Minimap2. Is this a question that would be more appropriate to ask on the Minimap2 Github?
the read is NOT paired (no mate) , mapped, on forward strand, it's a PRIMARY alignment
because this reads has also some supplementary alignemnts. Some parts of the read map elswhere, you should find some reads with the same read-name with the FLAG 2048 set.
Hi Pierre, Thanks for getting back to me. These supplemental alignments from the same read will not have the secondary flag set, so when I try to filter for primary alignments, I also capture these. But you are saying that there will always be one primary alignment that is not supplemental? How should I interpret a segment that is marked as both primary and supplemental?
-Natasha