Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • nZyMe
    Junior Member
    • Oct 2014
    • 3

    SAM format MD tag with gaps in reference?

    Hi there,

    first post as I haven't been able to find an answer to this despite perusing the forum search and the SAM specification:

    I'm trying to wrap my head around the optional MD tag in SAM files because a tool in my processing pipeline relies on this tag. In theory it should allow me to call SNPs/indels without looking up the reference sequence for a read. An example MD tag from a file I'm dealing with is

    MD:Z:2A11G14G7G9^C3

    read: GAGGAACCTTACCAAGGCTTGACATGTAGCTGCAAGCGCACGGAAACGTGTG
    CIGAR: 32M1I5M1I10M1D3M

    Now while the sum of the CIGAR M/I/S/=/X operations correctly equals the length of the read (52 bases, 53 when also considering the deletion/gap at position 50), I only get to 51 reference bases when I attempt to (manually) reconstruct the reference from the MD tag alone:

    2A11G14G7G9^C3

    in a "decompressed" form becomes

    ==A===========G==============G=======G=========-===

    becomes the following reference sequence (first line) as compared to the true reference sequence (second line):

    GAAGAACCTTACCAGGGCTTGACATGTAGGTGCAAGCGCACGGAAACCTGT
    GAAGAACCTTACCAGGGCTTGACATGTAGGTG-AAGCG-GCGGAAACGTCGTG

    The difference in length as well as the shift in the sequence both seem arise from the lack of a notation for the two gaps in the reference (positions 33 and 39).

    Now, am I just misunderstanding the MD tag? Do I always have to consider both the CIGAR string AND the MD tag to infer the reference sequence? Or is there a notation for gaps in the reference that I simply have overlooked in the SAM specification? What I've found so far is the Regex or permitted characters on page 6:

    [0-9]+(([A-Z]|\^[A-Z]+)[0-9]+)*

    and the footnote on page 7 claiming that the MD field ought to match the CIGAR string (which it obviously doesn't in my example).

    Thank you a lot for any insight and clarification!

    nZyMe
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    Actually, what I wrote above is wrong. MD tags don't store insertions, so yes, you need to look at both of them. The MD tag only stores information on the bases in the read that align to the reference, so insertions are ignored.

    Comment

    • nZyMe
      Junior Member
      • Oct 2014
      • 3

      #3
      Thanks for your response, dryan!

      Assuming it is a bug in the aligner (very likely as it is unpublished, alpha-stage software): what should the MD tag look like to match the CIGAR string? I can't seem to find a notation for the missing two indels. Once I've found it I can post a bug report with the developer and fix the files with a custom script.

      Comment

      • dpryan
        Devon Ryan
        • Jul 2011
        • 3478

        #4
        Have a look at my most recent reply above (or the reply I just sent to the samtools list). My initial post was incorrect (that's what happens when I post before drinking my coffee!).

        Comment

        • nZyMe
          Junior Member
          • Oct 2014
          • 3

          #5
          Thanks for the clarification! Too bad, I was hoping I could just skip the CIGAR string and focus on the MD tag alone.

          Comment

          Latest Articles

          Collapse

          • SEQadmin2
            Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
            by SEQadmin2



            Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
            ...
            07-09-2026, 11:10 AM
          • SEQadmin2
            Cancer Drug Resistance: The Lingering Barrier to Rising Survival
            by SEQadmin2



            Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

            There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
            07-08-2026, 05:17 AM
          • GATTACAT
            Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
            by GATTACAT
            Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
            07-01-2026, 11:43 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, Yesterday, 10:26 AM
          0 responses
          13 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-09-2026, 10:04 AM
          0 responses
          25 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-08-2026, 10:08 AM
          0 responses
          16 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-07-2026, 11:05 AM
          0 responses
          33 views
          0 reactions
          Last Post SEQadmin2  
          Working...