[Biopython] Nexus.Tree fails to import nexus tree file

Thomas Keller thomas.e.keller at gmail.com
Sat Sep 26 03:17:27 UTC 2009


I apologize if this has been addressed, I looked online and it does
not seem to be a general issue. I have several programs that generate
nexus files consisting entirely of trees; there is no sequence
information.  Can the Nexus parser not read this type of nexus file?
When I try to open the a file with:

from Bio.Nexus import Trees
tree_string=open('Analysis_tree_1a.tre').read()
tree=Trees.Tree(tree_string)

I get the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/home/thomas/Missing data in tree of Life
projects/tree_base_dat/S2000/<ipython console> in <module>()

/var/lib/python-support/python2.6/Bio/Nexus/Trees.pyc in
__init__(self, tree, weight, rooted, name, data, values_are_support,
max_support)
    70             # there's discrepancy whether newick allows
semicolons et the end

    71             tree=tree.rstrip(';')
---> 72
self._add_subtree(parent_id=root.id,tree=self._parse(tree)[0])
    73
    74     def _parse(self,tree):

/var/lib/python-support/python2.6/Bio/Nexus/Trees.pyc in _parse(self, tree)
    96         else:
    97             closing=tree.rfind(')')
---> 98             val=self._get_values(tree[closing+1:])
    99             if not val:
   100                 val=[None]

/var/lib/python-support/python2.6/Bio/Nexus/Trees.pyc in _get_values(self, text)
   172             values.append(nodecomment)
   173         else:
--> 174             values=[float(t) for t in text.split(':') if t.strip()]
   175         return values
   176

ValueError: invalid literal for float(): ;END


The associated nexus file I am trying to read is the following:

#NEXUS
BEGIN TREES;
       TRANSLATE
               1       'Pleurochrysis_pseudoroscoffensis_HAP48',
               2       'Pleurochrysis_placolithoides_HAP59bis',
               3       'Pleurochrysis_carterae_Von_Stosch',
               4       'Pleurochrysis_roscoffensis_HAP32',
               5       'Pleurochrysis_scherffelii_HAP11',
               6       'Pleurochrysis_sp_Langue_du_chat',
               7       'Pleurochrysis_elongata_CCMP874',
               8       'Pleurochrysis_gayraliae_HAP10',
               9       'Hymenomonas_coronata_HAP58bis',
               10      'Pleurochrysis_elongata_HAP79',
               11      'Ochrosphaera_verrucosa_HAP82',
               12      'Pleurochrysis_carterae_HAP1',
               13      'Pleurochrysis_dentata_HAP6',
               14      'Pleurochrysis_sp_MBIC10443',
               15      'Pleurochrysis_sp_MBIC10549',
               16      'Jomonlithus_littoralis_JE5',
               17      'Pleurochrysis_sp_CCMP875',
               18      'Pleurochrysis_sp_CCMP300',
               19      'Gloeothamnion_sp_HAPG' ;
       TREE 'Fig._2' =  [&R]
(11,((((((4,1,8,3,18),(10,7)),(12,(5,19))),6),2),(13,(14,17),15)),(9,16));

END;


Please let me know if/what I am doing wrong. Is the tree nexus file
malformed in some way?

Cheers,
Thomas Keller
Reply
		
Forward
		
		
[It's All Text!]



More information about the Biopython mailing list