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

CC BY-SA 4.0
2023-04-13T16:42:30.433Z
2023-04-13T16:47:55.333Z
2023-04-13T16:47:55.333Z
GavinBrelstaff
<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>

CC BY-SA 4.0
2020-12-02T09:05:22.567Z
What's your question?
user438383
CC BY-SA 4.0
2020-12-02T14:22:26.073Z
How to obtain CIGAR string given two sequences
Duke Glacia
CC BY-SA 4.0
2023-09-10T17:46:23.970Z
Hi @DukeGlacia could you check the answer? It looks pretty good, and thereafter consider accepting it?
M__
<phylogenetics><errors>
Pairwise alignment using CIGAR String
# 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 @DukeGlacia 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 and preferring the AAG contiguous
we can write:
  01234
  AAGCT     (ref) 
AAAAGGC     (query)

So the CIGAR string is 2I3M1I1D that is:

2I insert 2As  at the start:
3M match the 3 bases AAG
1I insert the G
1D delete the final T


---

