Biostar Beta. Not for public use.
Clustal Omega and Biopython
Entering edit mode
14 months ago
oonatoyou • 10

Hi All,

I am fairly new to python, and am trying to construct a phylogenetic tree through the following steps listed below. I have described my goals and the issue I am running into, if anyone could offer any advice it would be much appreciated, thank you!


  1. Create a multiple sequence alignment file (MSA file) in phylip format using Biopython to call on Clustal Omega
  2. Use PhyML Biopython module to create a maxiumum likelihood phylogenetic tree inference using the phylip MSA file in step 1 (PhyML only takes phylip format). This will output a new file in newick format
  3. Parse this newick file using the Phylo module in Biopython and create and manipulate the tree using matplotlib.


I cannot get step 1, the Clustal Omega portion described above, to output a MSA file in phylip format. According to the module outline, described here: , describing outfmt as phylip should be sufficient. However, when I run in commandline, I am given the following error:

clustalomega_cline = ClustalOmegaCommandline(infile = in_file, outfile = out_file, outfmt = phylip, verbose = True, auto = False)

NameError: name 'phylip' is not defined

Here is my code:

from Bio.Align.Applications import ClustalOmegaCommandline 
define input file
in_file = "in_filename.fasta"

# define output file (I have tried just adding .phylip or no .format)
out_file = "out_filename.phylip"

# get the command for Clustal Omega
# what I tried and what should work: outfmt = phylip
clustalomega_cline = ClustalOmegaCommandline(infile = in_file, outfile = out_file, verbose = True, auto = False)

# print the executable command

# The commandline will prompt you at this point to enter the line calling to your file, it should have this format:
# ./clustal-omega-1.2.3-macosx -i in_filename.fasta -o in_filename.phylip --auto -v

Please let me know if you have any insight into this issue, and thank you so much!

Entering edit mode
14 months ago
Carambakaracho ♦ 1.2k

This one is fairly simple I guess. The way you wrote it, Python has to interpret phylip as a variable. You never assigned any value to this variable when you use it the first time. Either you declare it as string, or assign the string phylip to a variable beforehand.l

clustalomega_cline = ClustalOmegaCommandline(infile = in_file, outfile = out_file, outfmt = 'phylip', verbose = True, auto = False)

PS: A very well written question, it's almost a shame the solution is so simple...

Entering edit mode

thank you @Carambakaracho !


Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.3