def scale_tree_branch(tree, format="newick"): tree_obj = None if os.path.exists(tree): tree_obj = Tree.get_from_path(tree, format) elif isinstance(tree, str): tree_obj = Tree(stream=StringIO(tree), schema=format) elif isinstance(tree, Tree): tree_obj = Tree if sum([ e.length > 1 for e in tree_obj.postorder_edge_iter()]): for e in tree_obj.postorder_edge_iter(): if e.length is not None: e.length = e.length/100 return tree_obj.as_newick_string()