All protocols

Align sequences with MAFFT

Build a multiple sequence alignment from a multi-FASTA with MAFFT, from the auto strategy to speed and accuracy tuning.

SDSomenath DuttaUpdated July 21, 2026

Prerequisites

  • MAFFT installed (`mafft` on your PATH)
  • A multi-FASTA of unaligned sequences (input.fasta)

1Run the auto strategy

Let MAFFT pick the accuracy-versus-speed strategy from your input size. It writes the gapped alignment to stdout, so redirect it to a file; the chosen strategy and progress print to stderr and stay visible.

bash
mafft --auto input.fasta > aligned.fasta

Expected output

nthread = 0
nthreadpair = 0
nthreadtb = 0
ppenalty_ex = 0
stacksize: 8192 kb
generating a scoring matrix for nucleotide (dist=200) ... done
Gap Penalty = -1.53, +0.00, +0.00

Making a distance matrix ..
   42 / 42
done.

Constructing a UPGMA tree (efffree=0) ...
   40 / 42
done.

Progressive alignment 1/2...
STEP    41 / 41
done.

Making a distance matrix from msa..
   40 / 42
done.

Constructing a UPGMA tree (efffree=1) ...
   40 / 42
done.

Progressive alignment 2/2...
STEP    41 / 41
done.

disttbfast (nuc) Version 7.520
alg=A, model=DNA200 (2), 1.53 (4.59), -0.00 (-0.00), noshift, amax=0.0
0 thread(s)

Strategy:
 FFT-NS-2 (Fast but rough)
 Progressive method (guide trees were built 2 times.)

If unsure which option to use, try 'mafft --auto input > output'.
For more information, see 'mafft --help', 'mafft --man' and the mafft page.

2Tune for speed or accuracy

For thousands of sequences, force the fast progressive mode and parallelize across cores: `mafft --retree 2 --thread 8 input.fasta > aligned.fasta`. For a small, accuracy-critical set use L-INS-i, which adds iterative refinement with local pairwise alignment (the command below).

bash
mafft --maxiterate 1000 --localpair input.fasta > aligned.fasta

Expected output

generating a scoring matrix for nucleotide (dist=200) ... done
Gap Penalty = -1.53, +0.00, +0.00

tbfast-pair (nuc) Version 7.520
alg=L, model=DNA200 (2), 1.53 (4.59), -0.00 (-0.00), noshift, amax=0.0
0 thread(s)

outputhat23=16
generating a scoring matrix for nucleotide (dist=200) ... done
LOCAL

Making a distance matrix ..
   42 / 42
done.

Constructing a UPGMA tree ...
   40 / 42
done.

Progressive alignment ...
STEP    41 / 41
done.

tbfast (nuc) Version 7.520
alg=A, model=DNA200 (2), 1.53 (4.59), -0.00 (-0.00), noshift, amax=0.0
0 thread(s)

Segment   1/  1    1- 640
STEP 006-041-1  identical.   
Converged.

done

dvtditr (nuc) Version 7.520
alg=A, model=DNA200 (2), 1.53 (4.59), -0.00 (-0.00), noshift, amax=0.0
0 thread(s)


Strategy:
 L-INS-i (Probably most accurate, very slow)
 Iterative refinement method (<16) with LOCAL pairwise alignment information

If unsure which option to use, try 'mafft --auto input > output'.
For more information, see 'mafft --help', 'mafft --man' and the mafft page.

Troubleshooting

Output looks unaligned or wraps onto long single lines

That is normal FASTA line wrapping, not a failed alignment. Open aligned.fasta in an alignment viewer, or add `--clustalout` to write a readable ClustalW block format.

Runs out of memory or is far too slow on a huge input

Drop `--localpair`/`--maxiterate` (L-INS-i is O(N^2) in memory) and use the progressive mode: `mafft --retree 2 --thread 8 input.fasta > aligned.fasta`.