Answers.Body: <p>Following the <a href="https://jef.works/blog/2017/03/28/CIGAR-strings-for-dummies/" rel="nofollow noreferrer">basic rules</a> and preferring the <code>AAG</code> contiguous
  we can write:</p>
  <pre><code>  01234
    AAGCT     (ref) 
  AAAAGGC     (query)
  </code></pre>
  <p>So the CIGAR string is <code>2I3M1I1D</code> that is:</p>
  <ul>
  <li><code>2I</code> insert 2<code>A</code>s  at the start:</li>
  <li><code>3M</code> match the 3 bases <code>AAG</code></li>
  <li><code>1I</code> insert the <code>G</code></li>
  <li><code>1D</code> delete the final <code>T</code></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-04-13T16:42:30.433Z
Answers.LastActivityDate: 2023-04-13T16:47:55.333Z
Answers.LastEditDate: 2023-04-13T16:47:55.333Z
Answers.UserDisplayName: GavinBrelstaff
Body: <p>I want to perform pairwise alignment and get the resulting CIGAR string (Concise Idiosyncratic Gapped Alignment Report). A fuller description being <a href="https://www.drive5.com/usearch/manual/cigar.html" rel="nofollow noreferrer">here</a></p>
  <p>The channel can emit insertions, deletions and substitution errors.</p>
  <p>For example, if the input was <em>AAGCT</em></p>
  <p>Then the output could be <em>AAAAGGC</em></p>
  <p>Where there were the following errors in the following positions.</p>
  <p>1, Insertion of A at first position
  2, Insertion of A at second position
  3, Insertion of G at the third position
  4, Deletion of T at the last position</p>
  <p>I want to know how I could obtain the CIGAR string given two sequences. In addition, could I use viterbi algorithm for this?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-02T09:05:22.567Z
Comments.Text: What's your question?
Comments.UserDisplayName: user438383
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-02T14:22:26.073Z
Comments.Text: How to obtain CIGAR string given two sequences
Comments.UserDisplayName: Duke Glacia
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-09-10T17:46:23.970Z
Comments.Text: Hi @DukeGlacia could you check the answer? It looks pretty good, and thereafter consider accepting it?
Comments.UserDisplayName: M__
Tags: <phylogenetics><errors>
Title: Pairwise alignment using CIGAR String
ThreadText: # Pairwise alignment using CIGAR String
  
  (Asked by: username_0 on 2020-12-02)
  
  I want to perform pairwise alignment and get the resulting CIGAR string (Concise Idiosyncratic Gapped Alignment Report). A fuller description being [here](https://www.drive5.com/usearch/manual/cigar.html)
  
  The channel can emit insertions, deletions and substitution errors.
  
  For example, if the input was *AAGCT*
  
  Then the output could be *AAAAGGC*
  
  Where there were the following errors in the following positions.
  
  1, Insertion of A at first position
  2, Insertion of A at second position
  3, Insertion of G at the third position
  4, Deletion of T at the last position
  
  I want to know how I could obtain the CIGAR string given two sequences. In addition, could I use viterbi algorithm for this?
  
  **Tags:** phylogenetics, errors
  
  > **Comments:**
  > **username_1**: What's your question?  
  > **username_0**: How to obtain CIGAR string given two sequences  
  > **username_2**: Hi @username_0 could you check the answer? It looks pretty good, and thereafter consider accepting it?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2023-04-13. Score: 1
  
  Following the [basic rules](https://jef.works/blog/2017/03/28/CIGAR-strings-for-dummies/) and preferring the `AAG` contiguous
  we can write:
  
  ```
    01234
    AAGCT     (ref) 
  AAAAGGC     (query)
  
  ```
  
  So the CIGAR string is `2I3M1I1D` that is:
  
  * `2I` insert 2`A`s at the start:
  * `3M` match the 3 bases `AAG`
  * `1I` insert the `G`
  * `1D` delete the final `T`
  
  
  ---
  
  