This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Identifying mate pair reads from SAM file without using QNAME

I am writing a C++ program that needs to process mate pair reads. I would like to avoid using the QNAME field in combination with the FLAG and PNEXT fields. I'd prefer not using the QNAME because the format seems to change depending on how the data was processed. Is it sufficient to simply check the FLAG (first in pair, second in pair) and PNEXT fields? Basically, I want a primary key that doesn't involve QNAME. I realize similar questions have been asked, but they did not satisfy me.

alignment

I'd prefer not using the QNAME because the format seems to change depending on how the data was processed

Please, give us an example of such case.

QNAME+FLAG is used by most (all?) tools (picard, samtools... )

I'm worried about one SAM file having the 0/1, 0/2 format and another having an identical QNAME format.

QNAME_0/1
QNAME_0/2

OR

QNAME
QNAME

1 answer

You'll need to combine the flags with PNEXT/RNEXT and additionally try to use the read names to break ties (you don't need to look for exact matches, just the longest exact substring match). On the plus side, only a few random version of most common aligners don't strip thing like "/1" off the read names.

Log in to answer this question.