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:
segul view align --input alignment.fastaIt is designed to be fast and can handle large alignments efficiently.
Layout
Section titled “Layout”From top to bottom, the viewer shows:
- 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.
- Overview: a strip showing the whole alignment, with a line marking the sites in view. Click or drag on it to jump.
- 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.
- 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.
- 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.
Detailed usage
Section titled “Detailed usage”Viewing several alignments
Section titled “Viewing several alignments”Pass several files, or a directory, to switch between them in the viewer:
segul view align --dir alignments/segul view align --input alignments/*.nexUse 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.
Data type
Section titled “Data type”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:
segul view align --input alignment.fasta --datatype aaColors and terminal themes
Section titled “Colors and terminal themes”The residue colors are made for dark terminals. If your terminal has a light background, use --theme light:
segul view align --input alignment.fasta --theme lightTerminals 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.
Chunks
Section titled “Chunks”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:
segul view align --input alignment.fasta --chunk 500Use [ and ] to move between chunks. Press Ctrl+K then P to show one chunk at a time.
Selecting and copying sequences
Section titled “Selecting and copying sequences”Press Space to select the sequence under the cursor, Shift+↑ or Shift+↓ to extend the selection, and Ctrl+A to select all. Then:
Ctrl+Ccopies 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+Ssaves them as<file name>-selected.fasin the current directory.
With no selection, both act on the sequence under the cursor.
Key bindings
Section titled “Key bindings”The key bindings follow Visual Studio Code. Press F1 or ? in the viewer to see them.
| Windows and Linux | macOS | Action |
|---|---|---|
← ↑ → ↓ | ← ↑ → ↓ | Move the cursor |
Ctrl+← / Ctrl+→ | Option+← / Option+→ | Jump 10 sites |
Home / End | fn+← / fn+→ | First / last site of the sequence |
Ctrl+Home / Ctrl+End | Ctrl+fn+← / Ctrl+fn+→ | First / last taxon |
PgUp / PgDn | Option+↑ / Option+↓ | Page through taxa |
Alt+PgUp / Alt+PgDn | Option+Shift+← / → | Page through sites |
[ / ] | [ / ] | Previous / next chunk |
Ctrl+G | Ctrl+G | Go to a site (120), a taxon, or taxon:120 |
Ctrl+F | Ctrl+F | Find a taxon by name |
Enter or F3 | Enter or fn+F3 | Next match (Shift for the previous one) |
+ / - / Ctrl+0 | + / - / Ctrl+0 | Zoom in / out / reset |
F2 or Ctrl+K C | Ctrl+K C | Cycle color mode |
F4 or Ctrl+K L | Ctrl+K L | Show or hide residue letters |
Ctrl+K P | Ctrl+K P | Show one chunk at a time |
Ctrl+B | Ctrl+B | Show or hide the chunk sidebar |
< / > | < / > | Narrow / widen the taxon names |
Space / Shift+↑ ↓ | Space / Shift+↑ ↓ | Select a sequence / extend the selection |
Ctrl+A | Ctrl+A | Select all sequences |
Ctrl+C | Ctrl+C | Copy selected sequences as FASTA |
Ctrl+S | Ctrl+S | Save selected sequences as FASTA |
Ctrl+PgUp / Ctrl+PgDn | Ctrl+fn+↑ / Ctrl+fn+↓ | Previous / next file |
Ctrl+P | Ctrl+P | Pick a file |
F1 or ? | ? | Show key bindings |
Ctrl+Q or Esc | Ctrl+Q or Esc | Quit (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.
All options
Section titled “All options”| Option | Description |
|---|---|
-d, --dir | Directory with alignments |
-i, --input | Alignment files. Allows wildcards |
-f, --input-format | Input format: auto (default), fasta, nexus, or phylip |
--datatype | Data type: ignore (default, detects DNA or amino acids), dna, aa |
--theme | Colors for a dark (default) or light terminal |
--chunk | Sites per chunk: 250, 500, 1000 (default), or 2000 |