This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Why perfectly match (150M) records are not primary alignment in SAM

I saw lot of record with perfect alignment (150M) but marked as secondary alignment in SAM file. For example those with FLAG number 339 or 419. The following one for example:

E00477:134:H2H2NCCXx:6:2203:29267:71384 419     chr1    14479   3       150M    =       14705   376     GTGGAGCCGTCCCCCCATGGAGCACAGGCAGACAGAAGTCCCCGCCCCAGCTGTGTGGCCTCAAGCCAGCCTTCCGCTCCTTGAAGCTGGTCTCCACACAGTGCTGGCTCCGTCACCCCCTCCCAAGGAAGTAGGTCTGAGCAGCTTGTC  AAAFFK<AF<A<AFFFKFKFKKKKKKKK7FK<AKAA7AFKFKK<FFKKKKKKKAKKKKKKKF,,7AAFKAK,,<AFFKKK7,,<FKKKKFAK7AFF<,AFA7AAA<K(FKKKA,,<FFAK7AK(,AFAF7,,7AFF,,<AA77,<77FAA  NH:i:2  HI:i:2  AS:i:296        nM:i:1

Why is that? Does that mean their corresponding primary alignment is also perfect and has higher base call quality? Any comments are appreciated!

bam sam alignment

furthermore, it's NOT perfect there is at least one mismatch :nm:i:1 and there is another alignment for this read: NH:i:2

Thanks for responding. I checked again and found out that those record with mapping quality of 255 are all primary alignment. It seems to me that mapping quality is the most important determinant for this, right?

I didn't pay much attention on 'nm' tap earlier. But how comes 'nm' shows mismatch when 150M? I thought 150M means every base match for read of 150bp long

I forgot to mention that I was using STAR. I did some searching and it seems to me that MAPQ is different for different aligner. For STAR, 255 means uniquely mapped

1 answer

Which aligner did you use, which settings? For example, for multi-mappers, STAR default settings will mark only one read pair as primary alignment, the other pairs will be marked as secondary. As Pierre pointed out, there are other alignments (NH:i:2) for this read pair.

I was using STAR. It turns out some of the columns in bam are aligner specific, right? For example MAPQ. Also, bam generated by different aligner may keep different information. For example, STAR excludes unmapped record while bwa keeps both mapped and unmapped record.

Log in to answer this question.