Skip to main content

Ancestral sequence reconstruction using Python

Project description


Ancestral Sequence Reconstruction in Python

PyASR offers a modern Python interface to PAML ("Phylogenetic Analysis by Maximum Likelihood")--tuned specifically for reconstruction ancestral protein/DNA sequences.

NOTE: PyASR currently only supports protein reconstructions. This is a work in progress.

Basic Usage

import phylopandas as pd
import dendropy as d
import pyasr

# Use phylopandas to read a set of ancestor.s
df_seqs = pd.read_fasta('test.fasta')

# Use dendropy to read in tree.
tree = d.Tree.get(path='tree.newick', schema='newick')

# Reconstruct nodes in tree.
tree, df_seqs, df_anc = pyasr.reconstruct(df_seqs, tree, working_dir='test', alpha=1.235)

# Write out ancestor dataframe to a CSV file.

We can visualize the ancestors side-by-side with the tree using inside of JupyterLab thanks to the ToyTree library.


This package is released on PyPi. You can install using pip:

pip install pyasr

To get the development version:

git clone
pip install -e .


The actual reconstruction calculation are done using PAML. This requires PAML to be installed and the codeml/baseml executables exported to your $PATH environment variable. Directions for installing PAML can be found on the PAML website.

The following Python dependencies are required for PyASR to work.

  • Pandas
  • Biopython
  • PhyloPandas
  • DendroPy

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
pyasr-0.6.1-py2.py3-none-any.whl (35.6 kB) Copy SHA256 hash SHA256 Wheel py2.py3
pyasr-0.6.1.tar.gz (31.8 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page