Entering edit mode
13.1 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()
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.
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?
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.
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.