All protocols

Trim a multiple sequence alignment with trimAl

Strip gappy, poorly-aligned columns from a multiple sequence alignment with trimAl before you infer a phylogenetic tree.

SDSomenath DuttaUpdated July 21, 2026

Prerequisites

  • trimAl installed (`trimal` on your PATH)
  • seqkit installed (for the before/after width check)
  • An aligned multi-FASTA with equal-length rows (e.g. from MAFFT)

1Auto-trim for maximum-likelihood tree inference

Run trimAl's `-automated1` heuristic, which chooses between gap- and similarity-based trimming to maximize signal for ML phylogenetics. It writes trimmed.fasta and prints nothing on success, so just confirm the file appears before moving on.

bash
trimal -in aligned.fasta -out trimmed.fasta -automated1

Expected output

# no stdout on success — trimAl writes trimmed.fasta with the low-quality columns removed

2Trim by an explicit gap threshold and inspect the result

Keep only columns where at most 20% of sequences carry a gap (`-gt 0.8`) and dump a colour-coded `-htmlout` report showing exactly which columns survived. Then compare alignment width before and after with seqkit — max_len should drop.

bash
trimal -in aligned.fasta -out trimmed.fasta -gt 0.8 -htmlout trimal_report.html
seqkit stats aligned.fasta trimmed.fasta

Expected output

file           format  type     num_seqs  sum_len  min_len  avg_len  max_len
aligned.fasta  FASTA   Protein        42   50,400    1,200    1,200    1,200
trimmed.fasta  FASTA   Protein        42   38,640      920      920      920

Troubleshooting

Almost every column disappears — trimmed.fasta is only a few residues wide

`-automated1` is aggressive on divergent alignments. Switch to a gentler explicit cutoff such as `-gt 0.5`, or let trimAl decide the columns with `-gappyout`.

ERROR: Sequences in the input file are not aligned

trimAl needs a true alignment with equal-length rows, not raw sequences. Align first, e.g. `mafft --auto input.fasta > aligned.fasta`, then feed aligned.fasta to trimAl.