Zsailer
pyasr
Python

Ancestral Sequence Reconstruction in Python

Last updated Apr 10, 2026
15
Stars
8
Forks
2
Issues
+15
Stars/day
Attention Score
8
Language breakdown
Python 100.0%
Files click to expand
README

PyASR

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

dfseqs = pd.readfasta('test.fasta')

Use dendropy to read in tree.

tree = d.Tree.get(path='tree.newick', schema='newick')

Reconstruct nodes in tree.

tree, dfseqs, dfanc = pyasr.reconstruct(dfseqs, tree, workingdir='test', alpha=1.235)

Write out ancestor dataframe to a CSV file.

dfanc.tocsv('ancestors.csv')

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

Install

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

pip install pyasr

To get the development version:

git clone cd pip install -e .

Dependencies

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
🔗 More in this category

© 2026 GitRepoTrend · Zsailer/pyasr · Updated daily from GitHub