Biostar Beta. Not for public use.
Phylip To Newick Format Conversion!
5
Entering edit mode
4.3 years ago
Thaman ♦ 3.2k
Finland

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()
ADD COMMENTlink
8
Entering edit mode
6.2 years ago
Paulo Nuin ♦ 3.7k
Canada

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

Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.1