Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Test for sites of contrasting conservation between gene clades.

Project Description

Compare protein sequence alignments. Identify diagnostic residues between the given “foreground” (FG) and “background” (BG) clades.

If you use this software in a publication, please cite our paper that describes it:

Talevich, E. & Kannan, N. (2013) Structural and evolutionary adaptation of rhoptry kinases and pseudokinases, a family of coccidian virulence factors. BMC Evolutionary Biology 13:117 doi:10.1186/1471-2148-13-117

Available at:

Freely distributed under the permissive BSD 2-clause license (see LICENSE).


A proper installation looks like:

python install

If you have setuptools installed, the dependencies on Biopython, BioFrills, SciPy and ReportLab will be fetched and installed automatically.

Optionally, CladeCompare can align your sequences for you if you have MUSCLE, HMMer3 or MAPGAPS installed.

If you have the dependencies installed, you can use this package in-place, without installing it. Just download the source code (git clone, or download the ZIP file and unpack it) and include the top-level directory in your system path, or add symbolic links to, and to an existing directory that’s in your path (e.g. ~/bin).


Finally, if you are on a Unix-like system (i.e. Linux, Mac or Cygwin), you can verify your installation by running the test suite. Change to the test/ directory and run make:

cd test

If CladeCompare is installed correctly, the program will run in several modes and generate output files. View the .html files in your web browser to see what happened.


Web interface

Launch the script and fill in the form in your web browser. The form accepts sequences in FASTA or CMA format, and you can upload an HMM profile to align unaligned FASTA sequence sets. (See below for details about each field.)

If you launched the application from the command line, press Ctrl-C (on Unix-like systems) to stop the web server application.

Note that only one instance of the server will run on your system at a time; if you launch twice in a row, another browser tab or window will open but the server will not restart.

Command line

The command-line interface provides the same functionality as the web interface, plus a few more options. To read the built-in help and option descriptions: --help

Two alignments are compared by specifying the foreground and background sets, in that order, as arguments:

# Compare two alignments fg_aln.seq bg_aln.seq

The program prints the following information for each column in the alignment(s):

  • The consensus amino acid types of the foreground and background
  • p-value indicating the significance of the contrast in amino acid frequencies
  • a little ASCII bar chart indicating contrast, based on the p-value.

P-values are adjusted for number of columns in the alignment with the Benjamini-Hochberg “step-up” multiple-testing correction (false discovery rate, FDR).

Redirect the output to a file with the extension “.out”:

# Compare two alignments fg_aln.seq bg_aln.seq > fg-v-bg.out

Or specify the output file name with the -o option (same effect): fg_aln.seq bg_aln.seq -o fg-v-bg.out

If you’re not using MAPGAPS, it would make sense to either:

  • Create a sequence alignment of all sequences, foreground and background, together; then divide the alignment into two FASTA files (e.g. by sequence ID).
  • Align both the foreground and background sets with hmmalign (HMMer3) using the same profile, then use a script (your own) to delete any insert columns.

In case you botch all that, CladeCompare will check then number of columns in the FG and BG alignments, and if they don’t match, will automatically run MUSCLE to align the alignments to each other.

To align the FASTA sequences with MAPGAPS on the fly, specify the profile name (minus the extension) with the --mapgaps flag:

# Align sequence sets w/ MAPGAPS, then compare test/scttlre-domain.fasta test/cdc2-domain.fasta --mapgaps test/CDK_CMGC \
    -o scttlre-v-cdc2.out

Pre-aligned sequences in CMA format (.cma) are also accepted:

# Use pre-aligned sequence sets (MAPGAPS "CMA" format) test/scttlre-domain.fasta_aln.cma test/cdc2-domain.fasta_aln.cma \
    -o scttlre-v-cdc2.out

Finally, given the ‘-p’ option, will write a “pattern” file listing the alignment column numbers with significant contrasts, in decreasing order (this can be useful input to other scripts of your own), as well as PDF files of paired sequence logos representing the foreground and background alignments around each significant site:

# Specify where the outputs go fg_aln.seq bg_aln.seq -o fg-v-bg.out -p fg-v-bg.pttrn


The script converts the “*.out” files to an HTML file showing the alignment of the FG and BG consensus sequences, with the FG sequence colorized to show per-site contrasts (red=significant difference, blue=non-significant/columns are similar), inserts (yellow) and deletions (gray gaps):

# Visualize the per-site contrasts as a colorized alignment scttlre-v-cdc2.out > scttlre-v-cdc2.html

Single- and multi-profile modes

If a single sequence set is given, the aligned columns are compared to the overall amino-acid frequencies of the alignment: subfam1.seq -o subfam1-single.out

When more than 2 sequence sets are given, each set is individually treated as a foreground and the rest treated as the background for evaluation:

# Compare several related alignments, e.g. all subfamilies subfam1.seq subfam2.seq subfam3.seq ...

This multi-mode generates and names the “*.out” files according to the corresponding sequence file names. You can visualize these all together:

# Visualize each subfamily's contrasts together subfam2.out subfam2.out subfam3.out ... > somefamily.html


Statistical tests (“-s” options) for column comparison:

gtest:(default) G-test for goodness-of-fit of FG amino acid counts vs. those of the BG column. BG frequencies include pseudocounts calculated from the amino acid frequencies of the full sequence set.
urn:Ball-in-urn model (binomial), a la CHAIN, for counts of the “consensus” amino acid type in FG and BG.
jsd:Jensen-Shannon divergence of column compositions, a la INTREPID.
Release History

Release History

This version
History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
CladeCompare-0.2.tar.gz (27.8 kB) Copy SHA256 Checksum SHA256 Source Jun 28, 2013 (35.8 kB) Copy SHA256 Checksum SHA256 Source Jun 28, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting