# Using --existing-alignment During Augur Align

**URL:** <https://nextstrain.discourse.group/t/using-existing-alignment-during-augur-align/81>\
**Category:** Help and Getting Started\
**Created:** [July 22, 2020, 9:56pm UTC](https://nextstrain.discourse.group/t/using-existing-alignment-during-augur-align/81 "2020-07-22T21:56:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![colejensen](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@colejensen](https://nextstrain.discourse.group/u/colejensen)\
**Post date:** [July 22, 2020, 9:56pm UTC](https://nextstrain.discourse.group/t/using-existing-alignment-during-augur-align/81/1 "2020-07-22T21:56:58Z")

</div>

Hello!

I’ve been trying to use the --existing-alignment subcommand in augur align. With smaller previous alignments the command works and the build run smoothly (less than 100 total genomes), but when I use larger previous alignments I get the following error:

ERROR: b’’  
shell exited 1 when running: mafft --add results/aligned.fasta.to\_align.fasta --keeplength --reorder --anysymbol --nomemsave --adjustdirection --thread 1 config/aligned.fasta.ref.fasta 1\> results/aligned.fasta 2\> results/aligned.fasta.log

Error during alignment  
[Wed Jul 22 17:36:11 2020]  
Error in rule align:  
jobid: 10  
output: results/aligned.fasta  
shell:

```
    augur align --existing-alignment config/aligned.fasta --sequences results/filtered.fasta --reference-sequence config/reference.gb --output results/aligned.fasta --remove-reference --fill-gaps
    (one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)

```

Removing output files of failed job align since they might be corrupted:  
results/aligned.fasta  
Shutting down, this might take some time.  
Exiting because a job execution failed. Look above for error message.

It’s worth noting that the build will run without error if I remove the ‘–existing-alignment’ line in the snakefile. Has anyone run into this issue before?

---

<div class="post-metadata">

**Author:** ![trs](https://yyz1.discourse-cdn.com/flex031/user_avatar/nextstrain.discourse.group/trs/32/5_2.png) [@trs](https://nextstrain.discourse.group/u/trs)\
**Post date:** [July 22, 2020, 10:59pm UTC](https://nextstrain.discourse.group/t/using-existing-alignment-during-augur-align/81/2 "2020-07-22T22:59:24Z")

</div>

Hi @colejensen, welcome. 🙂 I expect there’s more detail about the error in the log file `results/aligned.fasta.log`. Can you share that with us?

---

<div class="post-metadata">

**Author:** ![colejensen](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@colejensen](https://nextstrain.discourse.group/u/colejensen)\
**Post date:** [July 23, 2020, 2:18am UTC](https://nextstrain.discourse.group/t/using-existing-alignment-during-augur-align/81/3 "2020-07-23T02:18:47Z")

</div>

Hi @trs. This is the entirety of the results/aligned.fasta.log:

“Check results/aligned.fasta.to\_align.fasta”.

The aligned.fasta.to\_align.fasta file is empty.

---

<div class="post-metadata">

**Author:** ![andersonbrito](https://yyz1.discourse-cdn.com/flex031/user_avatar/nextstrain.discourse.group/andersonbrito/32/72_2.png) [@andersonbrito](https://nextstrain.discourse.group/u/andersonbrito)\
**Post date:** [July 25, 2020, 2:44am UTC](https://nextstrain.discourse.group/t/using-existing-alignment-during-augur-align/81/4 "2020-07-25T02:44:05Z")

</div>

Hey,

Last time I saw that error, it was caused by a corrupted fasta file with missing new line characters, which merged two genomes, like shown below.

> GGGCTATATAAACGTTTTCGCTTTTCCGTTTACGATATATAGTCTACTCTTGTGCAGAATGAATTCTCGTAACTACATAGCACAAGTAGATGTAGTTAACTTTAATCTCACATAGCAATCTTTAATCAGTGTGTAACATTAGGGAGGACTTGAAAGAGCCACCACATTTTCACCGAGGCCACGCGGAGTACGATCGAGTGTACAGTGAACAATGCTAGGGAGAGCTGCCTATATGGAAGAGCCCTAATGTGTAAAATTAATTTTAGTAGT\>HCOV-19/FINLAND/5MAY46S12/2020|EPI\_ISL\_481700|2020-05-05NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNAGATCTGTTCTCTAAACGAACTTTAAAATCTGTGTGGCTGTCACTCGGCTGCATGCTTAGTGCACTCACGCAGTATAATTAATAACTAATTACTGTCGTTGACAGGACACGAGTAACTCGTCTATCTTCTGCAGGCTGCTTACGGTTTCGTCCGTGTTGCAGCCGATCATCAGCACATCTAGGTTTT

---

<div class="post-metadata">

**Author:** ![colejensen](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@colejensen](https://nextstrain.discourse.group/u/colejensen)\
**Post date:** [July 27, 2020, 5:36pm UTC](https://nextstrain.discourse.group/t/using-existing-alignment-during-augur-align/81/5 "2020-07-27T17:36:19Z")

</div>

Hi @andersonbrito,

I can confirm that the alignment file used that produced this error doesn’t have merged genomes.

---

<div class="post-metadata">

**Author:** ![trs](https://yyz1.discourse-cdn.com/flex031/user_avatar/nextstrain.discourse.group/trs/32/5_2.png) [@trs](https://nextstrain.discourse.group/u/trs)\
**Post date:** [July 28, 2020, 5:09pm UTC](https://nextstrain.discourse.group/t/using-existing-alignment-during-augur-align/81/6 "2020-07-28T17:09:19Z")

</div>

> [@colejensen](#):
>
> The aligned.fasta.to\_align.fasta file is empty.

Ah, I’d bet this is what mafft errors about. The question then is:

1. Are there really no new sequences to align? That is, `results/filtered.fasta` contains no sequences which aren’t in `config/aligned.fasta`?
2. or, does Augur have a bug which makes it incorrectly write out an empty “to align” file?

Can you check on this? Or, if you provide the original input files to your `augur align` invocation, we can check. 🙂

---

<div class="post-metadata">

**Author:** ![colejensen](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@colejensen](https://nextstrain.discourse.group/u/colejensen)\
**Post date:** [July 29, 2020, 2:48am UTC](https://nextstrain.discourse.group/t/using-existing-alignment-during-augur-align/81/7 "2020-07-29T02:48:58Z")

</div>

Here are the links to the inputs you asked for.

> **[aligned.fasta](https://drive.google.com/file/d/1fJ3Eo3JSomLCCXjCoeQrS6t03dTzopSs/view?usp=sharing)**
>
> Google Drive file.

  

> **[filtered.fasta](https://drive.google.com/file/d/1dHDqDfxrvaeNtPU5ULRU5XLYawa6QuNt/view?usp=sharing)**
>
> Google Drive file.

  

> **[reference.gb](https://drive.google.com/file/d/1v55RByU6Yn2a8a6O2Sy__k_wYpLGwAnS/view?usp=sharing)**
>
> Google Drive file.

There should be new sequences to align, but I’d love a second opinion.

@trs thank you.

---

<div class="post-metadata">

**Author:** ![trs](https://yyz1.discourse-cdn.com/flex031/user_avatar/nextstrain.discourse.group/trs/32/5_2.png) [@trs](https://nextstrain.discourse.group/u/trs)\
**Post date:** [July 29, 2020, 6:49pm UTC](https://nextstrain.discourse.group/t/using-existing-alignment-during-augur-align/81/8 "2020-07-29T18:49:53Z")

</div>

Hmm, there are definitely lots of new sequences to align in those files. The files also work fine for me when I run the following locally:

```bash
augur align \
  --existing-alignment ~/Downloads/aligned.fasta \
  --sequences ~/Downloads/filtered.fasta \
  --reference-sequence ~/Downloads/reference.gb \
  --output /tmp/output.fasta \
  --remove-reference \
  --fill-gaps

```

I don’t know if it makes a difference, but what version of Augur are you using? `augur --version` will report it if you’re running Augur inside Conda. If you’re using the Nextstrain CLI, `nextstrain version --verbose` will report it.

So far the only way I can reproduce the error you’re seeing and Mafft’s “Check results/aligned.fasta.to\_align.fasta” message is by setting up inputs such that there’s nothing new to align.

---

<div class="post-metadata">

**Author:** ![andersonbrito](https://yyz1.discourse-cdn.com/flex031/user_avatar/nextstrain.discourse.group/andersonbrito/32/72_2.png) [@andersonbrito](https://nextstrain.discourse.group/u/andersonbrito)\
**Post date:** [October 10, 2020, 8:17pm UTC](https://nextstrain.discourse.group/t/using-existing-alignment-during-augur-align/81/9 "2020-10-10T20:17:34Z")

</div>

Hey,

I’m not sure if you found a solution for this issue, but I often get that error when the sequences in `aligned.fasta` match exactly the content in `filtered.fasta`.

The solution: try removing one of the sequences in `aligned.fasta`. MAFFT will only realign that extra sequence, and move on.

```
ERROR: b''
    shell exited 1 when running: mafft --add results/aligned.fasta.to_align.fasta --keeplength --reorder --anysymbol --nomemsave --adjustdirection --thread 1 config/aligned.fasta.ref.fasta 1> results/aligned.fasta 2> results/aligned.fasta.log

    Error during alignment

```

It could have other causes, though.

Cheers
