Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Import modules
from Bio import Phylo
from Bio.Phylo.TreeConstruction import DistanceCalculator
from Bio.Phylo.TreeConstruction import DistanceTreeConstructor
from Bio import AlignIO
# Read the sequences and align
aln ='msa.phy', 'phylip')
# Print the alignment
print aln
# Calculate the distance matrix
calculator = DistanceCalculator('identity')
dm = calculator.get_distance(aln)
# Print the distance Matrix
print('\nDistance Matrix\n===================')
# Construct the phylogenetic tree using UPGMA algorithm
constructor = DistanceTreeConstructor()
tree = constructor.upgma(dm)
# Draw the phylogenetic tree
# Print the phylogenetic tree in the terminal
print('\nPhylogenetic Tree\n===================')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment