add warning if input tree has long branches
@@ -65,6 +65,8 @@ class TreeAnc(object):
tree : str, Bio.Phylo.Tree
Phylogenetic tree. String passed is interpreted as a filename with
a tree in a standard format that can be parsed by the Biopython Phylo module.
+ Branch length should be in units of average number of nucleotide or protein
+ substitutions per site. Use on trees with longer branches (>4) is not recommended.
aln : str, Bio.Align.MultipleSequenceAlignment, dict
Sequence alignment. If a string passed, it is interpreted as the
@@ -317,12 +319,19 @@ class TreeAnc(object):
raise ValueError('TreeAnc: tree in %s as only %d tips. Please check your tree!'%(str(in_tree), self._tree.count_terminals()))
# remove all existing sequence attributes
+ branch_length_warning = False
for node in self._tree.find_clades():
node.branch_length = node.branch_length if node.branch_length else 0.0
+ if node.branch_length > ttconf.MAX_BRANCH_LENGTH:
+ branch_length_warning = True
if hasattr(node, "_cseq"):
node.__delattr__("_cseq")
node.original_length = node.branch_length
node.mutation_length = node.branch_length
+ if branch_length_warning:
+ self.logger("WARNING: TreeTime has detected branches that are longer than %d, TreeTime requires trees where branch length\n"
+ "is in units of average number of nucleotide or protein substitutions per site. Use on trees with longer branches\n"
+ "is not recommended."%(ttconf.MAX_BRANCH_LENGTH), 0, warn=True)
self.prepare_tree()
if self.data:
