View Single Post
Old 04-23-2018, 11:41 AM   #631
kbseah
Junior Member
 
Location: Germany

Join Date: Aug 2013
Posts: 6
Default Possible bug with bitflags in SAM alignments with ambig=all option

(Apologies if this shows up more than once, my posts keep disappearing...)
Hello Brian et al.,

The bitflags don't seem to be assigned correctly when the ambig=all option is used. The renaming of read pairs with keepnames=f also appears to be affected.

I am mapping Illumina paired reads with ambig=all to report all ambiguous alignments. From what I understand, the secondary alignments are indicated with the bitflag 0x100. For paired input, the alignments appear to be reported in the following order for each read pair:
  • read F primary alignment
  • read F secondary alignment(s)
  • read R primary alignment
  • read R secondary alignment(s)

I observed that with keepnames=f, there are two bugs (example below):
  • Reverse read is renamed to match the forward read only for the primary alignment. The original name (e.g. with the tag 2:N in the example below) is retained in the secondary alignment(s)
  • Secondary alignments of the reverse read are erroneously given bitflag 0x40 (first segment in the template, i.e. forward read) instead of 0x80 (last segment of the template, i.e. reverse read)

With keepnames=t, the original names are retained for both forward and reverse reads in both primary and secondary alignments, but the second bug above (misassignment of bitflags 0x40 and 0x80) is still there.

I first noticed the problem with bbmap v37.76 but it still occurs in v37.99.

Maybe I'm overlooking something, but this seems to be a bug. Has anyone else encountered this before? My apologies if this has been posted to this thread before. I didn't find anything relevant with search keywords 'keepnames' and 'ambiguous'.

Thank you!

** Examples **

Alignment columns QNAME and FLAG from SAM file with keepnames=f for a read pair showing the error
Code:
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 1:N:0:AAGGGAAT	99
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 1:N:0:AAGGGAAT	353
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 1:N:0:AAGGGAAT	353
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 1:N:0:AAGGGAAT	353
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 1:N:0:AAGGGAAT	353
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 1:N:0:AAGGGAAT	147
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 2:N:0:AAGGGAAT	337
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 2:N:0:AAGGGAAT	337
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 2:N:0:AAGGGAAT	337
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 2:N:0:AAGGGAAT	337
Alignment columns QNAME and FLAG from SAM file with keepnames=t for the same read pair as above
Code:
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 1:N:0:AAGGGAAT	99
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 1:N:0:AAGGGAAT	353
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 1:N:0:AAGGGAAT	353
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 1:N:0:AAGGGAAT	353
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 1:N:0:AAGGGAAT	353
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 2:N:0:AAGGGAAT	147
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 2:N:0:AAGGGAAT	337
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 2:N:0:AAGGGAAT	337
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 2:N:0:AAGGGAAT	337
HWI-ST863:279:H03F7ADXX:1:1107:5049:39482 2:N:0:AAGGGAAT	337
kbseah is offline   Reply With Quote