In [1]:
# Purpose: This script melds together your node labels from Diversitree with the tip-based data you've save in a csv. This allows you to appropriately colorize the tree in FigTree. If you don't use this script, the tree will have colors that extend to the parent node of the tips, leaving the tips black.
import dendropy
import sys
import pandas as pd
import os
from dendropy.utility.fileutils import find_files

In [2]:
taxa = dendropy.TaxonSet()

In [4]:
tree = dendropy.Tree.get_from_path('../Trees/TotalOptimization/Annotated/tip_annotated_2bnoterm',"newick",taxon_set=taxa, preserve_underscores=True,extract_comment_metadata=True)


---------------------------------------------------------------------------
DataParseError                            Traceback (most recent call last)
<ipython-input-4-314140ad943b> in <module>()
----> 1 tree = dendropy.Tree.get_from_path('../Trees/TotalOptimization/Annotated/tip_annotated_2bnoterm',"newick",taxon_set=taxa, preserve_underscores=True,extract_comment_metadata=True)

/home/april/anaconda/lib/python2.7/site-packages/dendropy/utility/iosys.pyc in get_from_path(cls, src, schema, **kwargs)
    234         return cls._parse_from_stream(stream=fsrc,
    235                 schema=schema,
--> 236                 **kwargs)
    237     get_from_path = classmethod(get_from_path)
    238 

/home/april/anaconda/lib/python2.7/site-packages/dendropy/dataobject/tree.pyc in _parse_from_stream(cls, stream, schema, **kwargs)
    483         kwargs["exclude_chars"] = True
    484         kwargs["exclude_trees"] = False
--> 485         d = DataSet(stream=stream, schema=schema, **kwargs)
    486         if len(d.tree_lists) == 0:
    487             raise ValueError("No trees in data source")

/home/april/anaconda/lib/python2.7/site-packages/dendropy/dataobject/dataset.pyc in __init__(self, *args, **kwargs)
     86             # if self.attached_taxon_set is not None:
     87             #     kwargs["taxon_set"] = self.attached_taxon_set
---> 88             self.process_source_kwargs(**kwargs)
     89 
     90     ###########################################################################

/home/april/anaconda/lib/python2.7/site-packages/dendropy/utility/iosys.pyc in process_source_kwargs(self, **kwargs)
    283             del(kwargs["stream"])
    284             schema = require_format_from_kwargs(kwargs)
--> 285             self.read(stream=stream, schema=schema, **kwargs)
    286         # else:
    287         #     from pudb import set_trace; set_trace()

/home/april/anaconda/lib/python2.7/site-packages/dendropy/dataobject/dataset.pyc in read(self, stream, schema, **kwargs)
    163         except error.DataParseError, x:
    164             x.decorate_with_name(stream=stream)
--> 165             raise x
    166 
    167     def process_taxon_set_directives(self, **kwargs):

DataParseError: Error parsing data source "../Trees/TotalOptimization/Annotated/tip_annotated_2bnoterm" on line 5 at column 5: Multiple labels found for the same leaf (taxon '#NEXUS' and label 'BEGIN')

In [ ]: