[BioPython] Bio.Nexus and Clustal tree files
Peter (BioPython List)
biopython at maubp.freeserve.co.uk
Wed Apr 26 14:16:21 UTC 2006
Hello again,
I have installed Frank Kauff's recent changes to Bio.Nexus from CVS, and
have actually got a tree loaded now :)
Here is my example script, which tries to load two tree files created
using ClustalX 1.83 (files previously sent to Frank off list)
(b) demo.dnd - Clustal guide tree in Newick format, no bootstraps
(b) demo.treb - Clustal NJ tree in Nexus format, with bootstraps
Example code starts here:
from Bio.Nexus import Nexus
for filename in [r"C:\TEMP\nexus\demo.dnd",
r"C:\TEMP\nexus\demo.treb"] :
input_file = open(filename,"r")
n=Nexus.Nexus(input_file)
input_file.close()
print "-----------------"
print "Filename:" + n.filename
print "Number of taxlabels = %i" % len(n.taxlabels)
print "Number of trees = %i" % len(n.trees)
for tree in n.trees :
print "Tree name: %s"% tree.name
print "Tree nodes: " + ", ".join(tree.get_taxa())
print "-----------------"
This gives the following output:
-----------------
Filename:C:\TEMP\nexus\demo.dnd
Number of taxlabels = 0
Number of trees = 0
-----------------
Filename:C:\TEMP\nexus\demo.treb
Number of taxlabels = 0
Number of trees = 1
Tree name: PAUP_1
Tree nodes: V_Harveyi_PATH, B_subtilis_YXEM, B_subtilis_GlnH_homo_YCKK,
YA80_HAEIN, FLIY_ECOLI, Deinococcus_radiodurans, HISJ_E_COLI, E_coli_GlnH
-----------------
As you can see, loading the ClustalX NEXUS output (*.treb) seems to work
without trouble (although n.taxlabels is an empty list... is this to be
expected?).
On the other hand, I don't get the tree for the Clustal guide tree file
(*.dnd) which is a pain. Do I need to load these files differently, as
they are Newick format, not NEXUS format?
Thank you
Peter
More information about the Biopython
mailing list