def phylogeneticTreeFromFile(self, treefile, file_format): dataset = Dataset() dataset.read(open(treefile, 'rU'), schema=file_format) dendropy_tree = dataset.tree_lists[0][0] tree = PhylogeneticTree(dendropy_tree) tree.calc_splits() delete_outdegree_one(tree._tree) return tree
def generate_tree_with_splits_from_str(tree_str, dataset): '''Uses `tree_str` and `dataset` to create a PhylogeneticTree object and calls `calc_splits` on the object before returning it. ''' tree_stream = StringIO(tree_str) tree_list = read_and_encode_splits(dataset, tree_stream) t = PhylogeneticTree(tree_list[0]) t.calc_splits() return t
def generate_tree_with_splits_from_str(tree_str, dataset, force_fully_resolved=False): '''Uses `tree_str` and `dataset` to create a PhylogeneticTree object and calls `calc_splits` on the object before returning it. ''' tree_stream = StringIO(tree_str) tree_list = read_and_encode_splits(dataset, tree_stream) t = tree_list[0] if force_fully_resolved: resolve_polytomies(t, update_splits=True) t = PhylogeneticTree(t) t.calc_splits() return t