As I read the SAM spec, the "X" CIGAR operator represents a mismatch. This seems useful as we can know where are the mismatches without looking at the reference genome. However, many popular aligners such as BWA do not output "X". Why do they omit "X"?
1 Answer
The SAM format originally had only M, I, D, N, S, H, and P CIGAR operators. See the original SAM specification (if you can view Apple Pages documents) and Table 1 in The Sequence Alignment/Map format and SAMtools (Li et al, 2009). This was in line with previous tools using CIGAR strings, notably exonerate which introduced them with just the M, I, and D operators.
BWA-backtrack was written contemporaneously with the SAM format in 2008 and 2009 (and published in May 2009). Its ChangeLog shows that it was outputting mismatch information in an MD tag from January 2009 and that MD was defined in the SAM specification of the time (and that the tag value's syntax was somewhat in flux in February 2009). The MD tag is also described in that early v1.0 Pages-formatted SAM specification.
The = and X CIGAR operators were introduced later in SAM v1.3 as a result of this lengthy samtools-devel mailing list thread. The characters used for the operators and the initial implementations were essentially in place by November 2009.
Since then, the =/X operators have not really taken over from M, as you've seen. There's probably a number of factors contributing to this:
- Their later introduction, long after the basic M/I/D operators and MD tag were well-established;
- Conceivably their being specific to SAM and unavailable in other CIGAR flavours;
- The MD tag still provides more information — X doesn't tell you what the mismatched reference bases were.
=
. $\endgroup$M
orX
/=
so if they omitX
they will also automatically omit=
$\endgroup$