Clustal Omega and Biopython
1
1
Entering edit mode
2.5 years 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!

GOALS

  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.

PROBLEM

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: https://biopython.org/DIST/docs/api/Bio.Align.Applications._ClustalOmega-pysrc.html#ClustalOmegaCommandline.__init__ , 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
print(clustalomega_cline)

# 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!

phylogenetic tree biopython clustal omega msa • 4.0k views
ADD COMMENT
2
Entering edit mode
2.5 years ago
Carambakaracho ★ 2.9k

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...

ADD COMMENT
0
Entering edit mode

thank you @Carambakaracho !

ADD REPLY

Login before adding your answer.

Traffic: 1067 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6