|
I'm ending up with inconsistent field ordering in my BAMs after running calmd to correct an initially-badly-generated MD field. The reads whose MD fields need correcting get corrected, but the MD field is moved to the last column. Here are two adjacent reads from the same BAM; the first one is in its original form, and the second has been modified by calmd.
Here's the second read, in its original form, before calmd:
I'm not particularly surprised to find optional fields in different orders in different BAMs from different sources; but two different orderings in the same BAM seems like a bit much! I'm on samtools 0.1.6, and this is SOLiD data mapped by BFAST. (I've also asked this question on the samtools mailing list, but thought I would help prime the pump over here, as well as giving the formatting tools a bit of a workout. Do people like the read all on one line like that, or is it more annoying to scroll than to read multiline data?) |
|
i've seen this in various sam-files as well, i think it's best to treat the optional field as an unordered hash of key - value pairs (or key:okey:value pairs). This is likely what various BAM/SAM implementations will do so the output will be dependent on their hash implementation. Sorry it took me a while to accept this answer, but...it's taken me a while to accept this answer. :) It does seem to be true, though, that SAM is an unordered hash rather than columnar tab-separated data. This still bugs me; it's fine when you're reading things programmatically but lousy when you're trying to do quick and dirty things at the command line. Thanks for helping pound the fact into my head, though!
(08 Jun '10, 12:47)
Jenn
|
|
There was a bug in BFAST with the MD tag, which was fixed to match that of samtools calmd in version 0.6.4d. Please download the latest release to see if the MD inconsistencies go away. The reordering wasn't BFAST's fault. Though I am on 0.6.4d now, and enjoying the good MD tags!
(08 Jun '10, 12:44)
Jenn
|
|
Does BFAST generate MD? Samtools moves MD when the MD generated by samtools is different from the one in the SAM/BAM file (you see the MD is different). You should check whether this is a bug in samtools or bfast. As to the ordering, there is never a rule on the order of optional tags. |