converting format of tree from newick to nexus

1,529 views
Skip to first unread message

parijat

unread,
Aug 3, 2011, 11:42:11 AM8/3/11
to The ETE toolkit, pari...@gmail.com
hi i want to convert newick format of tree to nexus , could it be done
through ete2 package

Jaime Huerta Cepas

unread,
Aug 3, 2011, 12:27:44 PM8/3/11
to eteto...@googlegroups.com
Unfortunately, ETE has no direct support for Nexus format :(

However, you could build a very simple export function following the nexus guidelines (http://www.bioperl.org/wiki/Nexus_tree_format):

from ete2 import Tree
t = Tree()
t.populate(10)

# Export as simple Nexus
tree_name = "MyTree"
print "#NEXUS\nBEGIN TREES;"
print "tree '%s' = %s" %(tree_name, t.write())
print "END;"

If you plan to include alignment and tree in the same file, you will need to add some more lines to the code. It should not be difficult for simple datasets. 

Jaime

parijat tripathi

unread,
Aug 4, 2011, 5:35:47 AM8/4/11
to eteto...@googlegroups.com
Thanks for the help.
--
KUMAR PARIJAT TRIPATHI
Evolutionary Bioinformatics
Institüt für Evolution ünd Biodiversitat
University of Münster
Hüfferstrasse 1, D48149 Münster, Germany
Germany

http://ieb.uni-muenster.de/bioinf/people/parijat
http://ieb.uni-muenster.de/



Reply all
Reply to author
Forward
0 new messages