Skip to main content

PyPI version DOI DOI Downloads Tests Quality Gate Status

alv: a command-line alignment viewer

View your DNA or protein multiple-sequence alignments right at your command line. No need to launch a GUI!

Note: alv requires Python v3.6 or later. Earlier versions may also work, but this has not been tested.

Latest feature additions

  • If you have more than one alignment in your input file, then the first alignment is output unless you use the --alignment-index (-ai) option to choose another.

  • alv is now adapted for use in Python notebooks (tested on Jupyter) through two convenience functions 'view' and 'glimpse'. Both functions take a BioPython alignment object and outputs a view of the alignment.

    Writing

    from Bio import AlignIO
    msa = AlignIO.read('PF00005.fa', 'fasta')
    import alv
    alv.view(msa)
    

    in a Jupyter notebook cell and evaluating will yield a colored alignment in the alv style.

    For large alignments, the glimpse function is convenient since a subset of the alignment, selected as an easily detected conserved region, is shown.

    alv.glimpse(msa)
    

    Look for more usage information view help(alv.view) in a notebook cell.

Features

  • Command-line based, no GUI, so easy to script viewing of many (typically small) MSAs.
  • Reads alignments in FASTA, Clustal, PHYLIP, NEXUS, and Stockholm formats, from file or stdin.
  • Output is formatted to suit your terminal. You can also set the alignment width with option -w.
  • Can color alignments of coding DNA by codon's translations to amino acids.
  • Guesses sequence type (DNA/RNA/AA/coding) by default. You can override with option -t.
  • Order sequence explicitly, alphabetically, or by sequence similarity.
  • Restrict coloring to where you don't have indels or where there is a lot of conservation.
  • Focus on variable columns with the options --only-variable and --only-variable-excluding-indels, contributed by nikostr, that constrains coloring to columns with variation and variation not counting indels.
  • The command alv -g huge_msa.fa displays cut-out of the MSA, guaranteed to fit one terminal page without scrolling or MSA line breaking, that is supposed to give you an idea of alignment quality and contents.
  • Write alv -r 20 huge_msa.fa to get a view of the MSA containing only 20 randomly selected sequences.

Install

Recommended installation is:

pip install --upgrade pip
pip install alv

BioPython is a dependency and will only get installed automatically with pip install alv if you are using Python v3.6 or later, because BioPython was apparently not on PyPi before that.

Install the commandline tool system-wide

If you would like to install the alv commandline tool system-wide, so that it is accessible regardless of which python environment you have loaded, or if you have loaded one at all, one way to do this is using the pipx installer.

After installing pipx using it's official installation instructions you can install alv with:

pipx install alv

After this, alv should be available as a command regardless of Python environment.

(Note that this only works for installing the alv commandline tool, not the Python library!)

Examples

Quick viewing of a small alignment:

alv msa.fa

This autodetects sequence type (AA, DNA, RNA, coding DNA), colors the sequences, and formats the alignment for easy viewing in your terminal. When applying alv to an alignment of coding DNA, the coding property is autodetected and colors are therefore applied to codons instead of nucleotides. Seven coding DNA sequences

View three sequences, accessions a, b, and c, from an alignment:

alv -so a,b,c msa.fa

Feed alignment to less, for paging support.

alv -k msa.fa | less -R

The -k option ensures that alv keeps coloring the alignment (by default, piping and redirection removes colors), and the -R option instructs less to interpret color codes.

Choose to view a sub-alignment:

alv -sa 30 60 msa.fa

This selects and views columns 30 to 59 of msa.fa, keeping track of the "original" columns indexes in the output.

Colors

A number of color schemes are available and more will be added. Use "--list-colors" (or the abbreviation "-lc" (previously used for "--list-codes", which is probably less used)) to see what is offered.

Consider using "-c okabe-ito" if you are color blind. This is a scheme suggested by Okabe and Ito (2008).

If you are not happy with the suggested defaults, or simply need, the Hello Kitty option, consider setting up an alias:

alias alv="alv -c hellokitty"

This ensures that alv is run with the desired option. Note that, if you temporarily want to use another scheme, the aliased call alv -c stockholm dna.fa effectively means alv -c hellokitty -c stockholm dna.fa which ignores the -c hellokitty part in favor of the latest choice (here: stockholm).

  • Okabe, M. & Ito, K. (2008). Color Universal Design (CUD): How to make figures and presentations that are friendly to colorblind people. Joint Research Center for Science Education*, Tokyo. https://jfly.uni-koeln.de/color/

For developers

  • Run pip install -e . to get an "editable" install, while coding.
  • Run python -m build to prepare a distributable file.
  • Run python -m unittest discover to run unit tests.

Screenshots

Full PFAM domain

All of the sequences in PFAM's seed alignment for PF00005

PF00005 seed MSA

Yeast sequences from PF00005

Using the option -sm YEAST, we reduce the alignment to the ones with a matching accession.

Small MSA from PF00005

Release files for alv 1.8.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alv 1.8.3
File Size Uploaded
alv-1.8.3.tar.gz 39.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for alv 1.8.3
File Interpreter ABI Platform
alv-1.8.3-py3-none-any.whl Python 3 none any Details

Total release size:76.2 kB

Release files / alv-1.8.3.tar.gz

Download URL alv-1.8.3.tar.gz
Size 39.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8f19648a53dada8be8664c4ec985b047a046e5997413936de97a70c0c5d65935
BLAKE2b-256 checksum
How to use checksums
c9aba091eff95824018b04bd96a920fe616bd6618b1bfd7dfebdd96e28cd35f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Release files / alv-1.8.3-py3-none-any.whl

Download URL alv-1.8.3-py3-none-any.whl
Size 36.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03e33a826cde7131e549ed836bb75689f2a31ae2f64be014fea40640c4b7b675
BLAKE2b-256 checksum
How to use checksums
5b224dd18373fa45d49949a8b46df242d27debdfcdeaa3129d00fa539815733c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Release history Release notifications | RSS feed

This release

1.8.3 This release

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

1 release file

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page