6
$\begingroup$

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"?

$\endgroup$
3
  • $\begingroup$ Strangely enough, the mismatch information is stored in the MD tag (at least for BWA), so it appears to have been a conscious decision rather than a matter of simplicity. $\endgroup$ Jun 3 '17 at 2:31
  • $\begingroup$ They also generally don't output =. $\endgroup$
    – Devon Ryan
    Jun 3 '17 at 9:54
  • 1
    $\begingroup$ @DevonRyan I think it will either output M or X/= so if they omit X they will also automatically omit = $\endgroup$
    – aechchiki
    Aug 30 '17 at 14:48
8
$\begingroup$

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$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.