Phylip To Newick Format Conversion!
1
5
Entering edit mode
14.5 years ago
Thaman ★ 3.3k

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

I tried to convert this way but don't 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()
phylip newick python • 13k views
ADD COMMENT
8
Entering edit mode
14.5 years ago
Paulo Nuin ★ 3.7k

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 COMMENT
3
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY

Login before adding your answer.

Traffic: 1587 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