Skip to content

View Alignments

Parts of a SEGUL commandThe command segul view align --input alignment.fasta --datatype aa has five parts: the program segul, the command view for the task group, the subcommand align for the task, the input --input alignment.fasta (file), and the option --datatype aa (optional).segulProgramviewCommandtask groupalignSubcommandtask--input alignment.fastaInputfile--datatype aaOptionsoptional

View alignments in an interactive viewer right in your terminal. It works like the SEGUI alignment viewer (in development). It is handy for checking alignments on a remote server or in a terminal session where a GUI is not available.

To view an alignment, use the following command:

Terminal window
segul view align --input alignment.fasta

It is designed to be fast and can handle large alignments efficiently.

From top to bottom, the viewer shows:

  1. Toolbar: the file name, the number of taxa and sites, the data type (DNA or amino acid), whether the sequences are unaligned, the color mode, the zoom level, and the current chunk.
  2. Overview: a strip showing the whole alignment, with a line marking the sites in view. Click or drag on it to jump.
  3. Legend: the residue colors. DNA shows A, C, G, and T. Amino acids show the Clustal X groups: hydrophobic, positive, negative, polar, aromatic, glycine, proline, and cysteine.
  4. Taxon names and residue grid: the names on the left, a ruler with site numbers on top, and the colored residues. Chunk boundaries are marked on the ruler.
  5. Status bar: the taxon, site, ungapped position, and residue under the cursor.

Press Ctrl+B to show the chunk sidebar. It lists each chunk of sites with its share of gaps and variable sites.

Pass several files, or a directory, to switch between them in the viewer:

Terminal window
segul view align --dir alignments/
Terminal window
segul view align --input alignments/*.nex

Use Ctrl+PgDn and Ctrl+PgUp to move to the next or previous file, or Ctrl+P to pick a file from a searchable list. Settings such as zoom and color mode carry over when you switch files.

SEGUL detects whether the sequences are DNA or amino acids from the residues. This is the default (--datatype ignore), unlike other SEGUL commands. To set the data type yourself, use --datatype dna or --datatype aa:

Terminal window
segul view align --input alignment.fasta --datatype aa

The residue colors are made for dark terminals. If your terminal has a light background, use --theme light:

Terminal window
segul view align --input alignment.fasta --theme light

Terminals that support 24-bit color show the exact SEGUI colors. Other terminals show the nearest of 256 colors. Most modern terminals support 24-bit color and report it with the COLORTERM environment variable.

Press F2 to cycle the color modes:

  • Base: each residue in its own color.
  • Mono: one color for residues and another for gaps.
  • Diff to first: residues that match the first sequence are shown as dots, so differences stand out.

The viewer splits the alignment into chunks of 1,000 sites by default. Use --chunk to pick 250, 500, 1000, or 2000 sites per chunk:

Terminal window
segul view align --input alignment.fasta --chunk 500

Use [ and ] to move between chunks. Press Ctrl+K then P to show one chunk at a time.

Press Space to select the sequence under the cursor, Shift+↑ or Shift+↓ to extend the selection, and Ctrl+A to select all. Then:

  • Ctrl+C copies the selected sequences as FASTA to the clipboard. This uses the terminal's clipboard support (OSC 52), which works in most modern terminals, including over SSH.
  • Ctrl+S saves them as <file name>-selected.fas in the current directory.

With no selection, both act on the sequence under the cursor.

The key bindings follow Visual Studio Code. Press F1 or ? in the viewer to see them.

Windows and LinuxmacOSAction
← ↑ → ↓← ↑ → ↓Move the cursor
Ctrl+← / Ctrl+→Option+← / Option+→Jump 10 sites
Home / Endfn+← / fn+→First / last site of the sequence
Ctrl+Home / Ctrl+EndCtrl+fn+← / Ctrl+fn+→First / last taxon
PgUp / PgDnOption+↑ / Option+↓Page through taxa
Alt+PgUp / Alt+PgDnOption+Shift+← / →Page through sites
[ / ][ / ]Previous / next chunk
Ctrl+GCtrl+GGo to a site (120), a taxon, or taxon:120
Ctrl+FCtrl+FFind a taxon by name
Enter or F3Enter or fn+F3Next match (Shift for the previous one)
+ / - / Ctrl+0+ / - / Ctrl+0Zoom in / out / reset
F2 or Ctrl+K CCtrl+K CCycle color mode
F4 or Ctrl+K LCtrl+K LShow or hide residue letters
Ctrl+K PCtrl+K PShow one chunk at a time
Ctrl+BCtrl+BShow or hide the chunk sidebar
< / >< / >Narrow / widen the taxon names
Space / Shift+↑ ↓Space / Shift+↑ ↓Select a sequence / extend the selection
Ctrl+ACtrl+ASelect all sequences
Ctrl+CCtrl+CCopy selected sequences as FASTA
Ctrl+SCtrl+SSave selected sequences as FASTA
Ctrl+PgUp / Ctrl+PgDnCtrl+fn+↑ / Ctrl+fn+↓Previous / next file
Ctrl+PCtrl+PPick a file
F1 or ??Show key bindings
Ctrl+Q or EscCtrl+Q or EscQuit (Esc first closes any open prompt)

You can also use the mouse. Scroll to move through taxa, hold Shift while scrolling to move through sites, and hold Ctrl while scrolling to zoom. Click a residue to move the cursor, click a taxon name to select it (Shift-click to select a range), and drag the line next to the names to resize them.

OptionDescription
-d, --dirDirectory with alignments
-i, --inputAlignment files. Allows wildcards
-f, --input-formatInput format: auto (default), fasta, nexus, or phylip
--datatypeData type: ignore (default, detects DNA or amino acids), dna, aa
--themeColors for a dark (default) or light terminal
--chunkSites per chunk: 250, 500, 1000 (default), or 2000

This material is based upon work supported by the National Science Foundation under grant numbers: DEB-1754393 and DEB-2244754. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation.