Question: Phylip To Newick Format Conversion!
5
gravatar for Thaman
8.9 years ago by
Thaman3.2k
Finland
Thaman3.2k wrote:

How can I convert PHYLIP (.phy) alignment file to Newick (.tree)

I tried to convert this way but dont think it's appropriate

input_handle = open("save.phy", "rU")
output_handle = open("example.tree","w")

alignments = AlignIO.parse(input_handle, "phylip")
AlignIO.write(alignments,output_handle, "nexus")

output_handle.close()
input_handle.close()
conversion file format • 7.6k views
ADD COMMENTlink modified 7 months ago by RamRS21k • written 8.9 years ago by Thaman3.2k
8
gravatar for Paulo Nuin
8.9 years ago by
Paulo Nuin3.7k
Canada
Paulo Nuin3.7k wrote:

One thing is one thing, another thing is another thing. You cannot convert those, because one is a tree and the other is an alignment. In the code you posted above you seem to be trying to convert phylip input file to nexus, if I'm not wrong.

From an alignment you can generate a tree, but the alignment can be either in nexus or phylip.

ADD COMMENTlink written 8.9 years ago by Paulo Nuin3.7k
3

You're mixing everything there. Muscle generates an alignment in Phylip format, the you use some Phylip app to get a tree (dnaml, dnapars, protpars, etc). This tree will be in Newick format and that's your phylogeny. Nexus is another input/output format (PAUP, MrBayes) and alignments and trees can be stored in Nexus format too.

ADD REPLYlink written 8.9 years ago by Paulo Nuin3.7k

My save.phy (format phylip) is an anlignment file outputted from MUSCLE. To generate phylogenetic tree i need nexus or newick format so i am trying to convert my save.phy into tree file so tree generation is possible. How can i improve it?

ADD REPLYlink written 8.9 years ago by Thaman3.2k

I am trying to figure out like you said to overcome my problem and understanding. But, i dont know how to get newick tree from my MUSCLE generated alignment with Phylip's application. For phylip app's there are no wrapper in biophython but EMBOSS does, is it for it's own applications or for phylip applications? Just give me hint how to write command line in python for EMBOSS app's or Phylip app's so i can perform phylogency on my MUSCLE generated alignment file.

ADD REPLYlink written 8.9 years ago by Thaman3.2k

EMBOSS has all Phylip's apps in its package. I'm not an expert on BioPython but the tutorial gives some examples on how to wrap EMBOSS apps in it. Check the answer to your other question and follow the link to BioPython's tutorial. Sorry that I could not help further.

ADD REPLYlink written 8.9 years ago by Paulo Nuin3.7k
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: 1501 users visited in the last hour