Skip to content

Instantly share code, notes, and snippets.

Created March 23, 2018 20:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Vini2/0723caa046c6b8e1d745a623f2695abb to your computer and use it in GitHub Desktop.
# 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