I want to perform pairwise alignment and get the resulting CIGAR string (Concise Idiosyncratic Gapped Alignment Report). A fuller description being here

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?

  • $\begingroup$ What's your question? $\endgroup$
    – user438383
    Commented Dec 2, 2020 at 9:05
  • 1
    $\begingroup$ How to obtain CIGAR string given two sequences $\endgroup$ Commented Dec 2, 2020 at 14:22
  • $\begingroup$ Hi @DukeGlacia could you check the answer? It looks pretty good, and thereafter consider accepting it? $\endgroup$
    – M__
    Commented Sep 10, 2023 at 17:46

1 Answer 1


Following the basic rules and preferring the AAG contiguous we can write:

  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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.