<p>The SAM format originally had only <strong>M</strong>, <strong>I</strong>, <strong>D</strong>, <strong>N</strong>, <strong>S</strong>, <strong>H</strong>, and <strong>P</strong> CIGAR operators.  See the <a href="https://github.com/samtools/hts-specs/tree/a9b16d4c54d8b2bf900b210b8319474163d7ce2a" rel="nofollow noreferrer">original SAM specification</a> (if you can view Apple Pages documents) and Table 1 in <a href="https://www.ncbi.nlm.nih.gov/pubmed/19505943" rel="nofollow noreferrer"><em>The Sequence Alignment/Map format and SAMtools</em></a> (Li <em>et al</em>, 2009).  This was in line with previous tools using CIGAR strings, notably <a href="http://www.ebi.ac.uk/about/vertebrate-genomics/software/exonerate" rel="nofollow noreferrer"><em>exonerate</em></a> which introduced them with just the <strong>M</strong>, <strong>I</strong>, and <strong>D</strong> operators.</p>

<p>BWA-backtrack was written contemporaneously with the SAM format in 2008 and 2009 (and <a href="https://www.ncbi.nlm.nih.gov/pubmed/19451168" rel="nofollow noreferrer">published in May 2009</a>).  Its <em>ChangeLog</em> shows that it was outputting mismatch information in an <strong>MD</strong> tag from January 2009 and that <strong>MD</strong> was defined in the SAM specification of the time (and that the tag value's syntax was somewhat in flux in February 2009).  The <strong>MD</strong> tag is also described in that early v1.0 Pages-formatted SAM specification.</p>

<p>The <strong>=</strong> and <strong>X</strong> CIGAR operators were introduced later in <a href="https://github.com/samtools/hts-specs/commit/07dc1c67a717a6c5cc9d65eeb8b3c99612744cde" rel="nofollow noreferrer">SAM v1.3</a> as a result of <a href="https://sourceforge.net/p/samtools/mailman/samtools-devel/thread/ee957a250907301016y22c96c5x2907a33c2e719da2%40mail.gmail.com/" rel="nofollow noreferrer">this lengthy samtools-devel mailing list thread</a>.  The characters used for the operators and the initial implementations were essentially in place by November 2009.</p>

<p>Since then, the <strong>=</strong>/<strong>X</strong> operators have not really taken over from <strong>M</strong>, as you've seen.  There's probably a number of factors contributing to this:</p>

<ul>
<li>Their later introduction, long after the basic <strong>M</strong>/<strong>I</strong>/<strong>D</strong> operators and <strong>MD</strong> tag were well-established;</li>
<li>Conceivably their being specific to SAM and unavailable in other CIGAR flavours;</li>
<li>The <strong>MD</strong> tag still provides more information — <strong>X</strong> doesn't tell you what the mismatched reference bases were.</li>
</ul>

CC BY-SA 3.0
2017-06-03T18:39:37.780Z
2017-06-08T09:10:32.403Z
2017-06-08T09:10:32.403Z
John Marshall
<p>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"?</p>

CC BY-SA 3.0
2017-06-03T02:31:42.760Z
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.
Scott Gigante
CC BY-SA 3.0
2017-06-03T09:54:08.713Z
They also generally don't output `=`.
Devon Ryan
CC BY-SA 3.0
2017-08-30T14:48:30.833Z
@DevonRyan I think it will either output `M` or `X`/`=` so if they omit `X` they will also automatically omit `=`
aechchiki
<bwa><sam>
Why most aligners do not output the "X" CIGAR operation?
# Why most aligners do not output the "X" CIGAR operation?

(Asked by: username_0 on 2017-06-02)

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

**Tags:** bwa, sam
> **Comments:**
> **username_1**: 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.  
> **username_2**: They also generally don't output `=`.  
> **username_3**: @DevonRyan I think it will either output `M` or `X`/`=` so if they omit `X` they will also automatically omit `=`  

---

## 1 answers

### Answer by username_4 on 2017-06-03. Score: 10 | Accepted answer

The SAM format originally had only **M**, **I**, **D**, **N**, **S**, **H**, and **P** CIGAR operators. See the [original SAM specification](https://github.com/samtools/hts-specs/tree/a9b16d4c54d8b2bf900b210b8319474163d7ce2a) (if you can view Apple Pages documents) and Table 1 in [*The Sequence Alignment/Map format and SAMtools*](https://www.ncbi.nlm.nih.gov/pubmed/19505943) (Li *et al*, 2009). This was in line with previous tools using CIGAR strings, notably [*exonerate*](http://www.ebi.ac.uk/about/vertebrate-genomics/software/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](https://www.ncbi.nlm.nih.gov/pubmed/19451168)). 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](https://github.com/samtools/hts-specs/commit/07dc1c67a717a6c5cc9d65eeb8b3c99612744cde) as a result of [this lengthy samtools-devel mailing list thread](https://sourceforge.net/p/samtools/mailman/samtools-devel/thread/ee957a250907301016y22c96c5x2907a33c2e719da2%40mail.gmail.com/). 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.


---

