Question: Clustal Omega and Biopython
1
gravatar for oonatoyou
6 months ago by
oonatoyou10
oonatoyou10 wrote:

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!

ADD COMMENTlink modified 6 months ago by Carambakaracho1.9k • written 6 months ago by oonatoyou10
2
gravatar for Carambakaracho
6 months ago by
Carambakaracho1.9k
Switzerland/Basel
Carambakaracho1.9k wrote:

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 COMMENTlink modified 6 months ago • written 6 months ago by Carambakaracho1.9k

thank you @Carambakaracho !

ADD REPLYlink modified 6 months ago • written 6 months ago by oonatoyou10
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 975 users visited in the last hour