<p>The MD string doesn't apply to soft or hard clipped regions,. so your example read becomes <code>43G42</code>. Since variant calling using something simplistic like this is only ever going to use the aligned portion, I guess there was never much reason to bother with adding in soft-clipping information. This also means that you need to parse the CIGAR string if you're using the MD string.</p>

CC BY-SA 3.0
2017-06-13T16:50:57.050Z
2017-06-13T17:01:26.013Z
2017-06-13T17:01:26.013Z
Devon Ryan
<p>I am trying to understand how the MD:Z tag is used. The following is from the <a href="https://samtools.github.io/hts-specs/SAMtags.pdf" rel="noreferrer">SAM Optional Fields Specification</a>, which gives an example but is not thorough. </p>

<blockquote>
  <p>The MD field aims to achieve SNP/indel calling without looking at the
  reference. For example, a string ‘10A5^AC6’ means from the leftmost
  reference base in the alignment, there are 10 matches followed by an A
  on the reference which is different from the aligned read base; the
  next 5 reference bases are matches followed by a 2bp deletion from the
  reference; the deleted sequence is AC; the last 6 bases are matches.
  The MD field ought to match the CIGAR string.</p>
</blockquote>

<p>Suppose I have a read that I want to soft clip at both ends. If the read starts with CIGAR <code>100M</code> and MD <code>50G49</code>, and I want to change the CIGAR to <code>7S86M7S</code>, what should the MD field become? </p>

<p>Is there a more complete explanation of what appears in the MD tag field?</p>

<file-formats><sam><cigar>
How should the SAM MD tag match the CIGAR string?
# How should the SAM MD tag match the CIGAR string?

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

I am trying to understand how the MD:Z tag is used. The following is from the [SAM Optional Fields Specification](https://samtools.github.io/hts-specs/SAMtags.pdf), which gives an example but is not thorough.

> The MD field aims to achieve SNP/indel calling without looking at the
> reference. For example, a string ‘10A5^AC6’ means from the leftmost
> reference base in the alignment, there are 10 matches followed by an A
> on the reference which is different from the aligned read base; the
> next 5 reference bases are matches followed by a 2bp deletion from the
> reference; the deleted sequence is AC; the last 6 bases are matches.
> The MD field ought to match the CIGAR string.

Suppose I have a read that I want to soft clip at both ends. If the read starts with CIGAR `100M` and MD `50G49`, and I want to change the CIGAR to `7S86M7S`, what should the MD field become?

Is there a more complete explanation of what appears in the MD tag field?

**Tags:** file-formats, sam, cigar

---

## 1 answers

### Answer by username_1 on 2017-06-13. Score: 5

The MD string doesn't apply to soft or hard clipped regions,. so your example read becomes `43G42`. Since variant calling using something simplistic like this is only ever going to use the aligned portion, I guess there was never much reason to bother with adding in soft-clipping information. This also means that you need to parse the CIGAR string if you're using the MD string.


---

