<p>Smith-Waterman is guaranteed to give you the best alignment given your choice of substitution matrix.  For a few such tiny sequences, it's what I would use.  Many implementations exist.</p>

CC BY-SA 4.0
2019-10-23T02:56:51.660Z
2019-10-23T02:56:51.660Z
Edward Kirton
<p>blastn should be able to output this format of alignment result, using the <code>--outfmt 0</code> option</p>

CC BY-SA 4.0
2019-09-16T21:23:07.267Z
2019-09-16T21:23:07.267Z
Jay Moore
<p>Is there any particular reason why you don't want a BAM output format? If the sequences are sufficiently long, then the CIGAR field from the SAM output of minimap2 could be used:</p>

<pre><code>minimap2 -a seq1.fa seq2.fa | samtools view | awk '{print $6}'
</code></pre>

CC BY-SA 4.0
2019-11-22T05:33:41.767Z
2019-11-22T05:33:41.767Z
gringer
<p>Perhaps you could use something like <code>SearchIO</code> to parse the output of BLAST, to get the desired alignment attributes: <a href="https://biopython.org/DIST/docs/api/Bio.SearchIO.BlastIO-module.html" rel="nofollow noreferrer">https://biopython.org/DIST/docs/api/Bio.SearchIO.BlastIO-module.html</a></p>

CC BY-SA 4.0
2019-09-16T18:40:37.133Z
2019-09-16T18:40:37.133Z
Alex Reynolds
<p>I have two sequences, say AAAGCTCGAGG and AAAGCGAGG. I need a convenient tool which shows me insertions or deletions between these, i.e. in this case something like</p>

<pre><code>AAAGCTCGAGG
|||||  ||||
AAAGC  GAGG
2bp deletion starting at base pair 5
</code></pre>

<p>and also insertions such as</p>

<pre><code>AAAGCTC GAGG
||||||| ||||
AAAGCTCTGAGG
1bp insertion at base pair 7
</code></pre>

<p>Does something like that exist? Blastn finds the alignment of course, but only outputs the <em>number</em> of gaps, not their <em>position</em>. I guess I could parse a pileup, but do not want to create a bam file from one of the sequences first, so samtools seems to be out. Any further ideas?</p>

CC BY-SA 4.0
2019-10-18T06:56:48.640Z
IMO you need to write custom code. I just done this (again) via pandas, albeit elegant its a lot of code. Its quite easy to do via Perl5.
M__
<samtools><indel><blastn>
Find indels between two short sequences
# Find indels between two short sequences

(Asked by: username_0 on 2019-09-16)

I have two sequences, say AAAGCTCGAGG and AAAGCGAGG. I need a convenient tool which shows me insertions or deletions between these, i.e. in this case something like
AAAGCTCGAGG
|||||  ||||
AAAGC  GAGG
2bp deletion starting at base pair 5

and also insertions such as
AAAGCTC GAGG
||||||| ||||
AAAGCTCTGAGG
1bp insertion at base pair 7

Does something like that exist? Blastn finds the alignment of course, but only outputs the number of gaps, not their position. I guess I could parse a pileup, but do not want to create a bam file from one of the sequences first, so samtools seems to be out. Any further ideas?

**Tags:** samtools, indel, blastn
> **Comments:**
> **username_1**: IMO you need to write custom code. I just done this (again) via pandas, albeit elegant its a lot of code. Its quite easy to do via Perl5.  

---

## 4 answers

### Answer by username_2 on 2019-10-23. Score: 1

Smith-Waterman is guaranteed to give you the best alignment given your choice of substitution matrix. For a few such tiny sequences, it's what I would use. Many implementations exist.


---

### Answer by username_3 on 2019-09-16. Score: 0

blastn should be able to output this format of alignment result, using the `--outfmt 0` option


---

### Answer by username_4 on 2019-11-22. Score: 0

Is there any particular reason why you don't want a BAM output format? If the sequences are sufficiently long, then the CIGAR field from the SAM output of minimap2 could be used:
minimap2 -a seq1.fa seq2.fa | samtools view | awk '{print $6}'


---

### Answer by username_5 on 2019-09-16. Score: 0

Perhaps you could use something like `SearchIO` to parse the output of BLAST, to get the desired alignment attributes: <https://biopython.org/DIST/docs/api/Bio.SearchIO.BlastIO-module.html>


---

